Task 5 of 8 · 0 solved · 8 to go0%
You can read the problem, but answers are checked only for signed-in students. Sign in to answer →

1.2 Variables — = versus ==

Lesson

= versus ==

= assigns — it puts a value into a variable. == compares two values and produces true or false. Mixing them up is a classic bug.

x = 5;    // assign: store 5 in x
x == 5    // compare: is x equal to 5?

▶ Try it: run this, then change something and run it again.



Which line stores the value 5 in x?


True or false?


Sort each piece of code by what it does.


What does == do?


Type exactly what this program prints.

public class Main { public static void main(String[] a){
    int x = 5;
    System.out.println(x == 5);
}}