What will be the output of the program?


			  		

Loading

Practice Flow Control –

What will be the output of the program?

int i = 0, j = 5;  
tp: for(;;) {
i++;
for (;;) {
if(i > --j) {
break tp;
}
}
System.out.println("i =" + i + ", j = " + j);

 

What will be the output of the program?


			  		

Loading

Practice Flow Control –

What will be the output of the program?

for(int i = 0; i < 3; i++) {      
switch(i) {
case 0: break;
case 1: System.out.print("one ");
case 2: System.out.print("two ");
case 3: System.out.print("three ");
}
}
System.out.println("done");

 

What will be the output of the program?


			  		

Loading

Practice Flow Control –

What will be the output of the program?

for (int i = 0; i < 4; i += 2) {     
System.out.print(i + " ");
}
System.out.println(i); /* Line 5 */

 

What will be the output of the program?


			  		

Loading

Practice Flow Control –

What will be the output of the program?

public class Switch2 { 
final static short x = 2;
public static int y = 0;
public static void main(String [] args) {
for (int z=0; z < 3; z++) {
switch (z) {
case x: System.out.print("0 ");
case x-1: System.out.print("1 ");
case x-2: System.out.print("2 ");
}
}
}
}

 

What will be the output of the program ?


			  		

Loading

Practice Flow Control –

What will be the output of the program ?

public class CommandArgsTwo {     
public static void main(String [] argh) {
int x;
x = argh.length;
for (int y = 1; y <= x; y++) {
System.out.print(" " + argh[y]);
}
}
}

and the command-line invocation is

java CommandArgsTwo 1 2 3

void start() {       
A a = n

Loading

Practice Garbage Collections –

void start() {       
A a = new A();
B b = new B();
a.s(b);
b = null; /* Line 5 */
a = null; /* Line 6 */
System.out.println("start completed"); /* Line 7 */
}

 

Which of the following are true statements?

  1. The 

Loading

Practice Objects and Collections –

Which of the following are true statements?

  1. The Iterator interface declares only three methods: hasNextnext and remove.
  2. The ListIterator interface extends both the List and Iterator interfaces.
  3. The ListIterator interface provides forward and backward iteration capabilities.
  4. The ListIterator interface provides the ability to modify the List during iteration.
  5. The ListIterator interface provides the ability to determine its position in the List.

x = 0; 
if (x1.hashCode() != x2

Loading

Practice hashCode() method –

x = 0; 
if (x1.hashCode() != x2.hashCode() )
x = x + 1;
if (x3.equals(x4) )
x = x + 10;
if (!x5.equals(x6) )
x = x + 100;
if (x7.hashCode() == x8.hashCode() )
x = x + 1000;
System.out.println("x = " + x);

and assuming that the equals() and hashCode() methods are property implemented, if the output is “x = 1111“, which of the following statements will always be true?

Which two statements are true about comparing two instances of the

Loading

Practice hashCode() method –

Which two statements are true about comparing two instances of the same class, given that  the equals()  and  hashCode() methods have been properly overridden?

  1. If the equals() method returns true, the hashCode() comparison == must return true.
  2. If the equals() method returns false, the hashCode() comparison != must return true.
  3. If the hashCode() comparison == returns true, the equals() method must return true.
  4. If the hashCode() comparison == returns true, the equals() method might return true.

Which statement is true?

Loading

Practice Garbage Collections –

Which statement is true?

Which statement is true?

Loading

Practice Garbage Collections –

Which statement is true?

Which statement is true?

Loading

Practice Garbage Collections –

Which statement is true?

What allows the programmer to destroy an object x ?

Loading

Practice Garbage Collections –

What allows the programmer to destroy an object x ?