Primitives - boolean & char QuizS2C Home « Primitives - boolean & char Quiz

Fundamentals Quiz 3

The quiz below tests your knowledge of the material learnt in Fundamentals - Lesson 4 - Primitives - boolean & char data types.

Question 1 : Which is a valid declaration of a char type?
- A char type must be initialized as a numeric or a single character enclosed in single quotes.
Question 2 : By default boolean variables are initialized with true in Java?
- By default boolean variables are initialized with <code>false</code> in Java.
Question 3 : A boolean is returned from a relational operator?
- A boolean IS returned from a relational operator.
Question 4 : What will be returned from the following code?

System.out.println("1 > 2? is " + (1 > 2));
- <code>1 > 2? is false</code> will be returned from the following code - <code>System.out.println("1 > 2? is " + (1 > 2))</code>.
Question 5 : Which of the following statements read in sequence is invalid?
- All of the statements are valid: because the <code>char</code> primitive type is an unsigned 16-bit type we can perform mathematics on this type as if it was an integer, remember though the range is 0 to 65,536
Question 6 : The boolean type can control the flow of an if Construct?
- The <code>boolean</code> type can control the flow of an <code>if</code> construct
Question 7 : What will be returned from the following code?

System.out.println("2 > 1? is " + (2 > 1));
- <code>2 > 1? is true</code> will be returned from the following code - <code>System.out.println("2 > 1? is " + (2 > 1));</code>.
Quiz Progress Bar Please select an answer


What's Next?

The next quiz on Java is all about method scope.