while Construct QuizJ8 Home « while Construct Quiz

The questions in this Java quiz are on the topics covered in the Java - Fundamentals section of the site. The table below lists the lesson used for each quiz, a description of the lesson content and the quiz number and questions associated with that lesson.

Fundamentals Quizzes Summary

Click on a lesson in the table to go to that lesson for a refresher on the topics for that quiz.

Click on a quiz in the table to go straight to the quiz for a particular lesson.

Fundamentals Lessons Description Quiz Info.
Lesson 2 - Code Structure & SyntaxFor this lesson we look at the code structure of a Java source file and look at some syntax.Quiz1
8 questions
Lesson 3 - Java VariablesThis lesson is about the variables we use in Java.Quiz2
7 questions
Lesson 4 - Primitives - boolean & char data typesThis lesson is about the boolean & char primitive data types available in Java.Quiz3
7 questions
Lesson 5 - Primitives - Numeric data typesIn this lesson we look at the numeric primitive data types available in Java.Quiz4
7 questions
Lesson 6 - Method ScopeIn this lesson we look at Java method scope and what scope and its definition mean.Quiz5
8 questions
Lesson 7 - Arithmetic OperatorsIn our first lesson on operators we look at the arithmetic operators available for use in Java.Quiz6
6 questions
Lesson 8 - Relational & Logical OperatorsIn our second lesson on operators we look at the relational & logical operators available for use in Java.Quiz7
6 questions
Lesson 9 - Assignment OperatorsIn our third lesson on operators we look at the assignment operators available for use in Java.Quiz8
6 questions
Lesson 10 - Bitwise Logical OperatorsIn our fourth lesson on operators we look at the Java bitwise logical operators.Quiz9
7 questions
Lesson 11 - Bitwise Shift OperatorsIn our fifth lesson on operators we look at the Java bitwise shift operators.Quiz10
7 questions
Lesson 12 - if ConstructIn this lesson we make a thorough investigation of the if constructQuiz11
8 questions
Lesson 13 - switch ConstructIn this lesson we look at the switch constructQuiz12
7 questions
Lesson 14 -for ConstructIn this lesson we investigate the for construct.Quiz13
7 questions
Lesson 15 - while ConstructThis lesson is all about the loop statements available in Java.This quiz.
8 questions

Fundamentals Quiz 14

The quiz below tests your knowledge of the material learnt in Fundamentals - Lesson 15 - while Construct.

Question 1 : We can nest a while construct in any other construct?
- We CAN nest a <code>while</code> construct in any other construct including another <code>while</code> construct.
Question 2 :A while loop is always tested for true after each iteration of the loop?
- A <code>while</code> loop is always tested for <code>true</code> BEFORE each iteration of the loop.
Question 3 : Which statement will immediately exit a while loop?
- The <code>break</code> statement will immediately exit a <code>while</code> loop.
Question 4 : What will be output from this code snippet?

int i = 1; while (i < 1) { System.out.println("Executing"); } System.out.println("Executing");
- 'Executing' will be output.
Question 5 : Which loop statement is always guaranteed to execute at least once?
- The <code>do while</code> loop is always guaranteed to execute at least once.
Question 6 : What will be output from this code snippet?

boolean a = false; while (a = true) { System.out.println("In the loop"); a = false; }
- This code will compile fine, but when run creates an endless loop that outputs 'In the loop' as each time we hit the <code>while</code> loop we assign <code>true</code> to the conditional expression.
Question 7 : How could we force the next iteration of a while loop?
- The <code>continue</code> statement will force the next iteration of a <code>while</code> loop.
Question 8 : The break statement exits all loops and continues at the next line?
- The <code>break</code> statement only exits the current loop. To exit all loops you would need to use the <code>break</code> statement with a <code>label</code> statement that points to the outermost loop.
Quiz Progress Bar Please select an answer

What's Next?

The next quiz on Java is all about Arrays.