5.10. Sample exam questions
What’s the output of the following code?
class Loop2 { public static void main(String[] args) { int i = 10; do while (i < 15) i = i + 20; while (i < 2); System.out.println(i); } }
- 10
- 30
- 31
- 32
What’s the output of the following code?
class Loop2 { public static void main(String[] args) { int i = 10; do while (i++ < 15) i = i + 20; while (i < 2); System.out.println(i); } }
- 10
- 30
- 31
- 32
Which of the following statements is true?
- The enhanced for loop can’t be used within a regular for loop.
- The enhanced for loop can’t be used within a while loop.
- The enhanced for loop can be used within a do-while loop.
- The enhanced for loop can’t be used within a switch construct.
- All of the above ...
Get OCA Java SE 8 Programmer I Certification Guide now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.