11. |
In java, ............ can only test for equality, where as .......... can evaluate any type of the Boolean expression.
|
||||||||
Answer:
Option (a) |
12. |
Which of the following for loops will be an infinite loop?
|
||||||||
Answer:
Option (d) |
13. |
Determine output:
public class Test{ public static void main(String args[]){ int i; for(i = 1; i < 6; i++){ if(i > 3) continue ; } System.out.println(i); } }
|
||||||||
Answer:
Option (d) |
14. |
Consider the following program written in Java.
class Test{ public static void main(String args[]){ int x=7; if(x==2); System.out.println("NumberSeven"); System.out.println("NotSeven"); } }What would the output of the program be?
|
||||||||
Answer:
Option (a) |
15. |
Determine output:
public class Test{ public static void main(String args[]){ int i, j; for(i=1, j=0;i<10;i++) j += i; System.out.println(i); } }
|
||||||||
Answer:
Option (a) |
16. |
What will be the value of y after execution of switch statement?
public class Test{ public static void main(String[] args){ int x = 3, y = 4; switch(x + 3){ case 6: y = 0; case 7: y = 1; default: y += 1; } } }
|
||||||||
Answer:
Option (b) |
17. |
What is the printout of the following switch statement?
char ch = 'a'; switch (ch){ case 'a': case 'A': System.out.print(ch); break; case 'b': case 'B': System.out.print(ch); break; case 'c': case 'C': System.out.print(ch); break; case 'd': case 'D': System.out.print(ch); }
|
||||||||
Answer:
Option (c) |
18. |
How many times will the following code print "Welcome to DIET"?
int count = 0; do { System.out.println("Welcome to DIET"); count++; } while (count < 10);
|
||||||||
Answer:
Option (c) |
19. |
What will be the result of the following code?
public class Test{ static public void main(String args[]){ //line 2 int i, j; for(i=0; i<3; i++){ for(j=1; j<4; j++){ i%=j; System.out.println(j); } } } }
|
||||||||
Answer:
Option (c) |
20. |
What all gets printed when the following program is compiled and run.
public class Test{ public static void main(String args[]){ int i, j=1; i = (j>1)?2:1; switch(i){ case 0: System.out.println(0); break; case 1: System.out.println(1); case 2: System.out.println(2); break; case 3: System.out.println(3); break; } } }
|
||||||||
Answer:
Option (d) |