| 1. |
Which of the following is used with the switch statement?
|
||||||||
|
Answer:
Option (c) |
| 2. |
What is the valid data type for variable “a” to print “Hello World”?
switch(a)
{
System.out.println("Hello World");
}
|
||||||||
|
Answer:
Option (d) |
| 3. |
Which of the following is not a decision making statement?
|
||||||||
|
Answer:
Option (d) |
| 4. |
Which of the following is not a valid jump statement?
|
||||||||
|
Answer:
Option (b) |
| 5. |
From where break statement causes an exit?
|
||||||||
|
Answer:
Option (d) |
| 6. |
Which of the following is not a valid flow control statement?
|
||||||||
|
Answer:
Option (a) |
| 7. |
switch(x)
{
default:
System.out.println("Hello");
}
Which two are acceptable types for x?
1. byte 2. long 3. char 4. float 5. Short 6. Long
|
||||||||
|
Answer:
Option (a) |
| 8. |
public void test(int x)
{
int odd = 1;
if(odd)
{
System.out.println("odd");
}
else
{
System.out.println("even");
}
}
Which statement is true?
|
||||||||
|
Answer:
Option (a) |
| 9. |
public class While
{
public void loop()
{
int x= 0;
while ( 1 ) /* Line 6 */
{
System.out.print("x plus one is " + (x + 1)); /* Line 8 */
}
}
}
Which statement is true?
|
||||||||
|
Answer:
Option (d) |
| 10. |
Determine output:
public class Test{
public static void main(String args[]){
int i;
for (i=1;i<6;i++){
if(i>3) contine;
}
System.out.println(i);
}
}
|
||||||||
|
Answer:
Option (d) |