Assignment Operators QuizJ8 Home « Assignment Operators Quiz
Fundamentals Quiz 8
The quiz below tests your knowledge of the material learnt in Fundamentals - 9 - Assignment Operators.
Question 1 : What will be output from the following code?
boolean a = false;
boolean b = false;
if (a &= b) {System.out.println("a: " + a + " b: " + b);}
-The <code>&=</code> assignment operator checks both operands for <code>true</code> values and assigns <code>true</code> or <code>false</code> to the first operand dependant upon the outcome of the expression, so the contents of the <code>if</code> construct will never be executed and hence nothing is output.
Quiz Progress Bar
Quiz 1
Code Structure & Syntax
Quiz 2
Java Variables
Quiz 3
Primitives - boolean
& char
data types
Quiz 4
Primitives - Numeric data types
Quiz 5
Method Scope
Quiz 6
Arithmetic Operators
Quiz 7
Relational & Logical Operators
Quiz 9
Bitwise Logical Operators
Quiz 10
Bitwise Shift Operators
Quiz 11
if
Construct
Quiz 12
switch
Construct
Quiz 13
for
Construct
Quiz 14
while
Construct
What's Next?
The next quiz on Java is all about Bitwise Logical Operators.