

MCQOPTIONS
Saved Bookmarks
This section includes 6 Mcqs, each offering curated multiple-choice questions to sharpen your Java Programming knowledge and support exam preparation. Choose a topic below to get started.
1. |
What is the valid data type for variable a to print Interview Mania ?
switch(p) { System.out.println("Interview Mania"); } |
A. | byte and short |
B. | char and long |
C. | byte and char |
D. | int and float |
E. | None of these |
Answer» D. int and float | |
2. |
What is the output of this program?
public class jump_statment_Example { public static void main(String args[]) { int p = 4; int q = 5; for ( ; q < 10; ++q) { if (q % p == 0) { continue; } else if (q == 10) { break; } else { System.out.print(q + " "); } } } } |
A. | 5 6 7 9 |
B. | 1 2 3 4 5 |
C. | 2 3 4 5 |
D. | 6 7 8 9 |
E. | None of these |
Answer» B. 1 2 3 4 5 | |
3. |
What is the output of this program?
public class selection_statement_Example { public static void main(String args[]) { int num1 = 10; int num2 = 20; if ((num2 = 5) == num1) { System.out.print(num2); } else { System.out.print(++num2); } } } |
A. | 5 |
B. | 4 |
C. | 6 |
D. | 7 |
E. | 5 |
Answer» D. 7 | |
4. |
What would be the output of the following codesnippet if variable p=20?
public class Result { public static void main(String args[]) { int p=20; if(p<=0) { if(p==0) { System.out.println("5 "); } else { System.out.println("10 "); } } System.out.println("15 "); } } |
A. | 10 |
B. | 50 |
C. | 15 |
D. | 20 |
E. | 30 |
Answer» D. 20 | |
5. |
What is the valid data type for variable a to print Interview Mania ? |
A. | byte and short |
B. | char and long |
C. | byte and char |
D. | int and float |
E. | None of these |
Answer» D. int and float | |
6. |
What would be the output of the following codesnippet if variable p=20? |
A. | 10 |
B. | 50 |
C. | 15 |
D. | 20 |
E. | 30 |
Answer» D. 20 | |