Flow Control Questions and Answers

Practice Mode
Showing 10 of 29 questions
Q21
What happens if the loop condition is always true?
  • A compile error
  • B infinite loop
  • C program stops
  • D JVM crash
Answer: Option B
Explanation: A true condition means loop never ends.
Q22
Which operator is used for NOT condition?
  • A &
  • B |
  • C !
  • D ^
Answer: Option C
Explanation: ! reverses boolean values.
Q23
Which control statement chooses one block among many?
  • A if
  • B if-else-if
  • C try-catch
  • D import
Answer: Option B
Explanation: if-else-if supports multi-branching.
Q24
In a for-loop, what part is optional?
  • A condition only
  • B initialization only
  • C update only
  • D all three
Answer: Option D
Explanation: Java allows all 3 sections optional in a for loop.
Q25
What will happen if break is missing in a switch case?
  • A compile error
  • B logical error
  • C fall-through
  • D program stops
Answer: Option C
Explanation: Without break, cases fall-through sequentially.
Q26
Which loop is preferred when condition checking is needed before entering loop?
  • A for
  • B while
  • C do-while
  • D switch
Answer: Option B
Explanation: while checks the condition first.
Q27
Which keyword handles multiple fixed value matching?
  • A switch
  • B if
  • C throws
  • D try
Answer: Option A
Explanation: switch compares expressions to multiple cases.
Q28
What type of loop is this? for(;;)
  • A invalid
  • B infinite loop
  • C while loop
  • D do-while loop
Answer: Option B
Explanation: All sections empty = infinite loop.
Q29
Which statement is used to transfer program control based on expression value?
  • A break
  • B switch
  • C return
  • D if
Answer: Option B
Explanation: switch allows control flow based on value matching.
Questions and Answers for Competitive Exams Various Entrance Test