Java Programming Multiple Choice Questions - Loops
This section focuses on the "Loops" in Java programming. These Multiple Choice Questions (MCQ) should be practiced to improve the Java programming skills required for various interviews (campus interviews, walk-in interviews, company interviews), placements and other competitive examinations.
1. A __________ statement allows us to execute a statement or group of statements multiple times.
A. array
B. loop
C. function
D. exception
View Answer
Ans : B
Explanation: A loop statement allows us to execute a statement or group of statements multiple times.
2. A __________ loop statement in Java programming language repeatedly executes a target statement as long as a given condition is true.
A. for
B. do-while
C. while
D. None of the above
View Answer
Ans : C
Explanation: A while loop statement in Java programming language repeatedly executes a target statement as long as a given condition is true.
3. Which loop guaranteed to execute at least one time?
A. for
B. do-while
C. while
D. All of the above
View Answer
Ans : B
Explanation: A do...while loop is similar to a while loop, except that a do...while loop is guaranteed to execute at least one time.
4. A for loop is useful when you know how many times a task is to be repeated.
A. TRUE
B. FALSE
C. Can be true or false
D. Can not say
View Answer
Ans : A
Explanation: True, A for loop is useful when you know how many times a task is to be repeated.
5. Which statement causes the loop to immediately jump to the next iteration of the loop?
A. Exit
B. Break
C. Jump
D. Continue
View Answer
Ans : D
Explanation: The continue keyword can be used in any of the loop control structures. It causes the loop to immediately jump to the next iteration of the loop.
6. What is the syntax of a continue is a single statement inside any loop?
A. Jump
B. Continue
C. Con
D. State-Continue
View Answer
Ans : B
Explanation: The syntax of a continue is a single statement inside any loop : continue;
7. Choose a valid loop name in Java below.
A. For
B. While
C. Do-while
D. All of the above
View Answer
Ans : D
Explanation: All of the above are valid loop in java
8. 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. Can not say
View Answer
Ans : A
Explanation: A BREAK statement inside a Loop like WHILE, FOR, DO WHILE and Enhanced-FOR causes the program execution exit Loop
9. 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 of the above
View Answer
Ans : D
Explanation: All of the above are examples of collection.
10. Break statement can be used to terminate a case in the switch statement?
A. Yes
B. No
C. Can be yes or no
D. Can not say
View Answer
Ans : A
Explanation: Yes, break can be used to terminate a case in the switch statement
Discussion