🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← All topics

Quiz: Java Control Flow: questions with answers

10 questions, each with the answer and a short explanation.

Take the timed quiz + get a certificate →
  1. Q1. What does this print? (code)
  2. Q2. How many times does a do-while loop run if the condition is false at the start?
  3. Q3. What does this print? (code)
  4. Q4. What does this print? (code)
  5. Q5. Which operator is the ternary operator?
  6. Q6. What does this print? (code)
  7. Q7. After int n = sc.nextInt(); the user typed 25 and pressed Enter. What does the next sc.nextLine() return?
  8. Q8. What does this print? (code)
  9. Q9. What does this print? (code)
  10. Q10. What happens with int x = 3; if (x = 5) { ... } in Java?