| 21. |
What will be the output?
public class Test{
public static void main(String args[]){
int i = 1;
do{
i--;
}while(i > 2);
System.out.println(i);
}
}
|
||||||||
|
Answer:
Option (d) |
| 22. |
What will be the result?
int i = 10;
while(i++ <= 10){
i++;
}
System.out.print(i);
|
||||||||
|
Answer:
Option (d) |
| 23. |
What will be the result of compiling and runnig the following code:
public class Test{
public static void main(String... args) throws Exception{
Integer i = 34;
int l = 34;
if(i.equals(l)){
System.out.println("true");
}else{
System.out.println("false");
}
}
}
|
||||||||
|
Answer:
Option (a) |
| 24. |
1. public class Test{
2. public static void main(String [] args){
3. int x = 0;
4. // insert code here
5. do{ } while(x++ < y);
6. System.out.println(x);
7. }
8. }
Which option, inserted at line 4, produces the output 12?
|
||||||||
|
Answer:
Option (c) |
| 25. |
What will be the result?
1. int i = 10;
2. while(i++ <= 10){
3. i++;
4. }
5. System.out.print(i);
|
||||||||
|
Answer:
Option (d) |
| 26. |
What is true about do statement?
|
||||||||
|
Answer:
Option (a) |
| 27. |
What is true about a break?
|
||||||||
|
Answer:
Option (b) |
| 28. |
What would be the output of the following code snippet if variable a=10?
if(a<=0)
{
if(a==0)
{
System.out.println("1 ");
}
else
{
System.out.println("2 ");
}
}
System.out.println("3 ");
|
||||||||
|
Answer:
Option (d) |
| 29. |
What will be the output of the following Java program?
class Output
{
public static void main(String args[])
{
int a = 5;
int b = 10;
first:
{
second:
{
third:
{
if (a == b >> 1)
break second;
}
System.out.println(a);
}
System.out.println(b);
}
}
}
|
||||||||
|
Answer:
Option (d) |
| 30. |
What will be the output of the following Java program?
class Output
{
public static void main(String args[])
{
final int a=10,b=20;
while (a
|
||||||||
|
Answer:
Option (d) |