Exam 1z0-819 All QuestionsBrowse all questions from this exam
Question 17

Given:

and the code fragment:

Which three code fragments, at line n1, prints SPRING? (Choose three.)

    Correct Answer: C, D, G

    To print the enum constant SPRING, we need statements that properly reference this constant. The statement `System.out.println(Season.SPRING);` directly prints the SPRING constant. Using `System.out.println(Season.valueOf("SPRING"));` also prints SPRING as it retrieves the enum constant with the specified name. Lastly, `System.out.println(sA[1]);` works because the `values()` method returns the array of enum constants in the order they are declared, so accessing the element at index 1 gives us SPRING. Options involving invalid method calls or incorrect data types will either result in errors or not output the expected value.

Discussion
JGR_77Options: CDG

CDG System.out.println(Season.SPRING); System.out.println(Season.valueOf("SPRING")); System.out.println(sA[1]);

StavokOptions: CDG

A prints 1 B produces an error : method values in enum Question17 cannot be applied to given types; E produces an error : no suitable method found for valueOf(char) F prints Winter

Ankit1010Options: CDG

C, D, G is the correct answer. System.out.println(sA[1]); System.out.println(Season.valueOf("SPRING")); System.out.println(Season.SPRING);

RP384Options: CDG

cardinal will not print String, valueOf(c) will produce exception.

d7bb0b2Options: CDG

values metod, not aceptt parameters , B is incorrect, C D AND G CORRECT

d7bb0b2Options: CDE

C,D AND E. is correct

StavokOptions: CDG

ANSWER IS C,D & G

Leksh_geethOptions: CDG

Answer is CDG