

MCQOPTIONS
Saved Bookmarks
This section includes 38 Mcqs, each offering curated multiple-choice questions to sharpen your Java knowledge and support exam preparation. Choose a topic below to get started.
1. |
What is the output of the Java code snippet below? |
A. | A |
B. | AAAA |
C. | No Output |
D. | Compiler error |
Answer» D. Compiler error | |
2. |
Is it possible to break all loops with a single BREAK with a Label statement? (YES/NO) |
A. | YES |
B. | NO |
C. | - |
D. | - |
Answer» B. NO | |
3. |
The keyword "goto" can be used in Java programs with labels. (TRUE/FALSE) |
A. | FALSE |
B. | TRUE |
C. | - |
D. | - |
Answer» B. TRUE | |
4. |
State TRUE or FALSE. You can exit an inner loop without using a BREAK statement but with a CONTINUE and Label on the outer loop. |
A. | FALSE |
B. | TRUE |
C. | - |
D. | - |
Answer» C. - | |
5. |
Choose rules for naming a Label in Java below. |
A. | The name of a label or identifier may start only with Alphabet, Underscore ( _ ) or Dollar ($) symbol |
B. | A label is kept before the loop in general |
C. | Duplicate label names are not allowed |
D. | All |
Answer» E. | |
6. |
A BREAK-WITH-LABEL or CONTINUE-WITH-LABEL are used in particular in Java to select __ loop either to Break or Continue. |
A. | Inner loop |
B. | Outer loop |
C. | - |
D. | - |
Answer» C. - | |
7. |
A BREAK or CONTINUE statement applies only to the ___ loop. |
A. | Inner loop or the loop containing break or continue |
B. | always Outer loop |
C. | Sometimes inner loop, sometimes outer loop |
D. | None |
Answer» B. always Outer loop | |
8. |
What is the output of the Java code snippet? |
A. | 1,2, |
B. | 1,2,4,5, |
C. | 3,6, |
D. | Compiler error |
Answer» C. 3,6, | |
9. |
What is the output of the Java program with Enhanced FOR loop below? |
A. | BRAZIL,CHILE,SYDNEY, |
B. | BRAZIL,CHILE, |
C. | BRAZIL, |
D. | Compiler error |
Answer» C. BRAZIL, | |
10. |
An Enhanced FOR loop in Java misses ___ and __ compared to the old-style FOR loop. |
A. | Speed and Easiness |
B. | Initialization, Increment/Decrement |
C. | Semicolons, Variables |
D. | None |
Answer» C. Semicolons, Variables | |
11. |
What is the output of Java Enhanced FOR loop below? |
A. | MOGLI, |
B. | MOGLI,SHAREKHAN, |
C. | MOGLI,SHAREKHAN,BALU, |
D. | Compiler error |
Answer» D. Compiler error | |
12. |
An enhanced FOR loop work with only Collection type data. Examples of Collection are ___. |
A. | Array Class type or any regular array variable |
B. | ArrayList |
C. | HashMap, HashSet |
D. | All |
Answer» E. | |
13. |
The Enhanced FOR loop in Java was introduced by ___. |
A. | JDK 4 |
B. | JDK 5 |
C. | JDK 6 |
D. | JDK 7 |
Answer» C. JDK 6 | |
14. |
In Java language, BREAK or CONTINUE statements can be implemented inside a Loop only with the help of ___ statements to avoid never-ending loops. |
A. | IF ELSE |
B. | SWITCH |
C. | ENUM |
D. | None |
Answer» B. SWITCH | |
15. |
A Loop in Java language may contain ___. |
A. | Any loop |
B. | IF-ELSE statements |
C. | SWITCH statements |
D. | All |
Answer» E. | |
16. |
Any loop can be nested inside any loop in Java. (TRUE/FALSE). |
A. | FALSE |
B. | TRUE |
C. | - |
D. | - |
Answer» C. - | |
17. |
State TRUE or FALSE. In a FOR loop, the Initialization-part, Condition-part and Increment/Decrement part can be empty. |
A. | FALSE |
B. | TRUE |
C. | - |
D. | - |
Answer» C. - | |
18. |
What is the output of the below Java program with FOR loop? |
A. | 1,2,3,4, |
B. | 0,1,2,3,4 |
C. | Compiler error |
D. | None |
Answer» D. None | |
19. |
What is the output of the below Java code? |
A. | true,true,true,true, |
B. | true,false,false,true |
C. | true,false,true,true |
D. | Compiler error |
Answer» D. Compiler error | |
20. |
What is the output of the below Java code with a FOR loop? |
A. | 1,2,3,4, |
B. | 1,2,3,4 |
C. | 1,2,3,4,5, |
D. | 1,2,3,4,5 |
Answer» B. 1,2,3,4 | |
21. |
What is the output of the below java program that implements nesting of loops? |
A. | 1,2,3,4,1,2,3,4, |
B. | 1,2,3,4, |
C. | 1,2,3,1,2,3, |
D. | 1,2,3, |
Answer» C. 1,2,3,1,2,3, | |
22. |
What is the value of "age" in the below Java program with a DO-WHILE loop? |
A. | 20 |
B. | 21 |
C. | Compiler error |
D. | None |
Answer» C. Compiler error | |
23. |
What is the main difference between a WHILE and a DO-WHILE loop in Java? |
A. | WHILE loop executes the statements inside of it at least once even if the condition is false. |
B. | DO-WHILE loop executes the statements inside of it at least once even if the condition is false. |
C. | WHILE loop is fast. |
D. | DO-WHILE loop is fast. |
Answer» C. WHILE loop is fast. | |
24. |
What is the output of the below Java program with WHILE, BREAK and CONTINUE? |
A. | 0,1,2,3,4, |
B. | 1,2,3,4, |
C. | 1,2,3,4 |
D. | Compiler error |
Answer» C. 1,2,3,4 | |
25. |
What is the output of the below Java program with a decrement operator and WHILE-loop? |
A. | 4 3 2 1 |
B. | 3 2 1 |
C. | Compiler error |
D. | None |
Answer» B. 3 2 1 | |
26. |
An Increment operator "++" and/or a Decrement operator "--" are used along with a Loop-Counter variable in Java. (TRUE / FALSE). |
A. | FALSE |
B. | TRUE |
C. | - |
D. | - |
Answer» C. - | |
27. |
A loop in Java generally contains a Loop-Counter variable. State TRUE or FALSE. |
A. | FALSE |
B. | TRUE |
C. | - |
D. | - |
Answer» C. - | |
28. |
Choose the Java-Code below with a never-ending loop. |
A. | while(true); |
B. | for(;true;); |
C. | do |
D. | All |
Answer» E. | |
29. |
A CONTINUE statement inside a Loop like WHILE, FOR, DO-WHILE and Enhanced-FOR causes the program execution ___ the loop. |
A. | Skip |
B. | Skip present iteration and continue with next iteration of the loop |
C. | Exit |
D. | None |
Answer» C. Exit | |
30. |
A BREAK statement inside a Loop like WHILE, FOR, DO WHILE and Enhanced-FOR causes the program execution ___ Loop. |
A. | Exit |
B. | Continuation with next iteration |
C. | Never exit |
D. | None |
Answer» B. Continuation with next iteration | |
31. |
State TRUE or FALSE. A WHILE loop in Java executes the statements at least once even the condition is not satisfied. |
A. | FALSE |
B. | TRUE |
C. | - |
D. | - |
Answer» B. TRUE | |
32. |
Choose the correct syntax of an Enhanced FOR loop in Java below. |
A. | for(Type variable: Collection) |
B. | for(Type variable; Collection) |
C. | for(Collection: Type variable) |
D. | None |
Answer» B. for(Type variable; Collection) | |
33. |
Choose the correct syntax of the DO WHILE loop in Java below. |
A. | do |
B. | do |
C. | do while(condition) |
D. | None |
Answer» B. do | |
34. |
Choose the correct Syntax of FOR loop in Java below. |
A. | for(initialization; condition; increment-or-decrement) |
B. | for(condition; increment-or-decrement; initialization) |
C. | for(increment-or-decrement; condition; initialization) |
D. | None |
Answer» B. for(condition; increment-or-decrement; initialization) | |
35. |
Choose the correct syntax of the WHILE loop in Java below. |
A. | while(condition) |
B. | while(condition); |
C. | while |
D. | None |
Answer» B. while(condition); | |
36. |
Every loop in Java has a condition that should be ___ in order to proceed for execution. (TRUE / FALSE) |
A. | FALSE |
B. | TRUE |
C. | - |
D. | - |
Answer» C. - | |
37. |
Choose a valid loop name in Java below. |
A. | for |
B. | while |
C. | do while |
D. | All |
Answer» E. | |
38. |
What is a Loop in Java programming language? |
A. | A Loop is a block of code that is executed repeatedly as long as a condition is satisfied. |
B. | A Loop is a block of code that is executed only once if the condition is satisfied. |
C. | A Loop is a block of code that is executed more than 2 times if the condition is satisfied. |
D. | None |
Answer» B. A Loop is a block of code that is executed only once if the condition is satisfied. | |