Enum with two constants

Report a typo

You have an enum Role with two constants: ADMIN and USER.

Which lines of the code below print true?

Role role1 = Role.ADMIN;
Role role2 = Role.ADMIN;
Role role3 = Role.USER;

System.out.println(role1 == Role.ADMIN);  // (1)
System.out.println(role1.equals(role2)); // (2)
System.out.println(role1 == role2);    // (3)
System.out.println(role1 == role3);    // (4)
Select one or more options from the list
___

Create a free account to access the full topic