Given the code fragment string shirts new string22

  • No School
  • AA 1
  • rinothemaster
  • 91

This preview shows page 42 - 47 out of 91 pages.

QUESTION 64 Given the code fragment:String shirts[][]=newString[2][2];shirts[0][0]="red";shirts[0][1]="blue";shirts[1][0]="small";shirts[1][1]="medium"; Which code fragment prints red: blue: small: medium?
Background image
A) for(intindex=1;index<2;index++)for(intidx=1;idx<2;idx++){amount = 0; System.out.print(shirts[index][idx]+" :");}} B) for(intindex=0;index<2;++index)for(intidx=0;idx<index;++idx){ String name="sfsfsf";name.length();System.out.print(shirts[index][idx]+" :");}}C) for(String c: shirts){for(String s : sizes){System.out.println(s +:);}}} index++; } D) for(int index=0;index<2;){for(int idx=0;idx<2;){System.out.print(shirts[index][idx]+:);idx++;}index++;} A. Option A B.Option BC.Option CD.Option DAnswer:DGiven the code fragment:publicclassTest {voidreadCard(intcardNo) throwsException{System.out.println("Reading Card");}voidcheckCard(intcardNo) throwsRuntimeException{// line n1System.out.println("Checking Card");}64 A.
Background image
publicstaticvoidmain(String[] args){Test ex=newTest();intcardNo=12344;ex.checkCard(cardNo); //line n2ex.readCard(cardNo); //line n3}}What is the result? Given the code fragment:publicstaticvoidmain(String[] args){StringBuilder sb=newStringBuilder(5);String s=""if(sb.equals(s)){System.out.println("Match 1");} elseif(sb.toString().equals(s.toString())){System.out.println("Match 2");}else{System.out.println("No Match");} }What is the result? ; QUESTION 67 Answer B
Background image
Given:package p1;public class Acc{int p;private int q;protected int r;public int s;}Test.javapackae p2;import p1.Acc;public class Test extends Acc{public static void main(String[] args){Acc obj=new Test(); }}Which statement is true? Question 68 Given:Base.java:classBase{publicvoidtest(){System.out.println("Base ");}}DerivedA.java:classDerivedA extendsBase{publicvoidtest(){System.out.println("DerivedA ");}}
Background image
DerivedB.java: classDerivedB extendsDerivedA {publicvoidtest(){System.out.println("Derived B");}publicstaticvoidmain(String[] args) {// TODOAuto-generated method stubBase b1=newDerivedB();Base b2=newDerivedA();Base b3=newDerivedB();b1=(Base)b3;Base b4=(DerivedA)b3b1.test();b4.test();}}What is the result?A)Base DerivedAB)BaseDerivedBC)DerivedB DerivedBD)DerivedB DerivedA E)A classcast Exception is thrown at runtime;
Background image
Image of page 47

You've reached the end of your free preview.

Want to read all 91 pages?

  • Fall '19
  • Madrid Metro, Metropolitana di Napoli, public void readBook

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture