Question from the Java - Fundamentals test

Write a Java program to print the remainder of a number divided by 2.

Archived

Given this code :

public static void main(String[] args){
    int a = 2;
    a + = 2;
    System.out.println(a% 2);
}

What will be displayed in the console?

Author: PierreStatus: Archived(New question!)Question passed 1130 times
2
Community Evaluations
developer avatar
Miruna
14/09/2022
There is a space between + and = in 3rd line (a + = 2), which will lead to an error.