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

What will be the output of the program?


			  		

Loading

Practice Flow Control –

What will be the output of the program?

public void foo( boolean a, boolean b) {      
if(a) {
System.out.println("A"); /* Line 3 */
}
else if(a && b) { /* Line 5 */
System.out.println( "A && B");
}
else {/* Line 8 */
if ( !b ) {
System.out.println( "notB") ;
}
else {
System.out.println( "ELSE" ) ;
}
}
}

 

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

What will be the output of the program ?


			  		

Loading

Practice Flow Control –

What will be the output of the program ?

public class Test {     
public static void main(String [] args) {
signed int x = 10;
for (int y=0; y<5; y++, x--)
System.out.print(x + ", ");
}
}

 

What will be the output of the program?


			  		

Loading

Practice Flow Control –

What will be the output of the program?

public class TestDogs {     
public static void main(String [] args) {
Dog [][] theDogs = new Dog[3][];
System.out.println(theDogs[2][0].toString());
}
}
class Dog {
}

 

public class F0091 {
public v

Loading

Practice Flow Control –

public class F0091 {
public void main( String[] args ) {
System.out.println( "Hello" + args[0] );
}
}

What will be the output of the program, if this code is executed with the command line:

java F0091 world

What will be the output of the program?


			  		

Loading

Practice Flow Control –

What will be the output of the program?

boolean bool = true;  
if(bool = false) /* Line 2 */ {
System.out.println("a");
} else if(bool) /* Line 4 */ {
System.out.println("b");
} else if(!bool) /* Line 6 */ {
System.out.println("c"); /* Line 7 */
} else {
System.out.println("d");
}

 

What will be the output of the program?


			  		

Loading

Practice Flow Control –

What will be the output of the program?

public class If2 {     
static boolean b1, b2;
public static void main(String [] args) {
int x = 0;
if ( !b1 ) /* Line 7 */ {
if ( !b2 ) /* Line 9 */ {
b1 = true;
x++;
if ( 5 > 6 ) {
x++;
}
if ( !b1 )
x = x + 10;
else if ( b2 = true ) /* Line 19 */
x = x + 100;
else if ( b1 | b2 ) /* Line 21 */
x = x + 1000;
}
}
System.out.println(x);
}
}

 

What will be the output of the program?


			  		

Loading

Practice Flow Control –

What will be the output of the program?

public void foo( boolean a, boolean b) {      
if(a) {
System.out.println("A"); /* Line 3 */
}
else if(a && b) { /* Line 5 */
System.out.println( "A && B");
}
else {/* Line 8 */
if ( !b ) {
System.out.println( "notB") ;
}
else {
System.out.println( "ELSE" ) ;
}
}
}