Flow Control Questions and Answers

Practice Mode
Showing 10 of 29 questions
Q11
What data types can a switch statement operate on in Java?
  • A int, String, enum
  • B long only
  • C float only
  • D boolean only
Answer: Option A
Explanation: switch supports int, byte, short, char, String, enum.
Q12
Which keyword is used to test multiple conditions?
  • A switch
  • B if-else
  • C goto
  • D check
Answer: Option B
Explanation: if-else handles multiple branching conditions.
Q13
Which operator checks both conditions must be true?
  • A ||
  • B &&
  • C !
  • D =
Answer: Option B
Explanation: && is logical AND.
Q14
Which loop executes zero or more times?
  • A do-while
  • B for
  • C both for and while
  • D none
Answer: Option C
Explanation: for and while run only if condition is true.
Q15
What will “continue” inside a for-loop do?
  • A exit loop
  • B restart program
  • C skip to next iteration
  • D stop JVM
Answer: Option C
Explanation: continue ignores remaining code in that iteration.
Q16
Which statement is illegal in switch?
  • A break
  • B default
  • C continue
  • D case
Answer: Option C
Explanation: continue cannot be used to control switch flow.
Q17
What is used to repeat a block until a condition becomes false?
  • A class
  • B loop
  • C method
  • D exception
Answer: Option B
Explanation: loops manage repeated execution.
Q18
Which statement returns control to the caller method?
  • A break
  • B end
  • C return
  • D exit
Answer: Option C
Explanation: return ends method execution.
Q19
The condition inside an if statement must be a:
  • A float
  • B boolean
  • C int
  • D char
Answer: Option B
Explanation: Java if requires a boolean expression.
Q20
Which keyword is used to label loops?
  • A mark
  • B tag
  • C label
  • D none (user-defined name)
Answer: Option D
Explanation: Labels in Java are user-defined identifiers.
Questions and Answers for Competitive Exams Various Entrance Test