Zodiac signs

Report a typo

You are given an enum Zodiac with 12 constants:

public enum Zodiac {
    ARIES,
    TAURUS,
    GEMINI,
    CANCER,
    LEO,
    VIRGO,
    LIBRA,
    SCORPIO,
    SAGITTARIUS,
    CAPRICORN,
    AQUARIUS,
    PISCES
}

Here, two references to enum Zodiac fields were created:

Zodiac capricorn = Zodiac.CAPRICORN;
Zodiac leo = Zodiac.LEO;

Let's run the program with each of the following code lines.

Match them with the result they produce.

Match the items from left and right columns
System.out.println(capricorn.name());
Zodiac taurus = Zodiac.valueOf("TAURUS");
Zodiac virgo = Zodiac.valueOf("virgo");
System.out.println(leo.equals(Zodiac.TAURUS));
System.out.println(Zodiac.AQUARIUS.ordinal());
it prints 10
"CAPRICORN" is printed
IllegalArgumentException is thrown
Zodiac.TAURUS object is assigned
it prints "false"
___

Create a free account to access the full topic