OCA Java SE 8 Mock Exam 2 - OCA Mock Question 14








Question

What is the result of the following operation?

System.out.println(4 % 3); 
  1. 0
  2. 1
  3. 2
  4. 3




Answer



B

Note

The % operator is the modulo operator and returns the remainder.

public class Main {
  public static void main(String[] args) {
    System.out.println(4 % 3); 
  }
}

The code above generates the following result.