exam questions

Exam 1z0-819 All Questions

View all questions & answers for the 1z0-819 exam

Exam 1z0-819 topic 1 question 67 discussion

Actual exam question from Oracle's 1z0-819
Question #: 67
Topic #: 1
[All 1z0-819 Questions]

Given this enum declaration:



Examine this code:

System.out.println(Alphabet.getFirstLetter());

What code should be written at line 3 to make this code print A?

  • A. static String getFirstLetter() { return Alphabet.values()[1].toString();
  • B. static String getFirstLetter() { return A.toString(); }
  • C. final String getFirstLetter() { return A.toString(); }
  • D. String getFirstLetter() { return A.toString(); }
Show Suggested Answer Hide Answer
Suggested Answer: B 🗳️

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
ASPushkin
6 months, 2 weeks ago
Selected Answer: B
answer: B interesting that Alphabet.A.getFirstLetter() will work for CD
upvoted 1 times
...
d7bb0b2
1 year ago
Selected Answer: B
A-> Missing } ,and if this is fixed, Alphabet.values()[1] => print B B-> ok C- > instance method so => Alphabet.getFirsletter() throw compilation error D-> same as C C AND D only works in an element of enum: Alphabet.A.getFirstLetter() not in static context Alphabeg.getFirstletter()
upvoted 1 times
...
d7bb0b2
1 year ago
TWO OPTIONS ARE OK: A AND B; C AND D , are invalid because ther aren't static so cannot call with Alphabet.method().
upvoted 1 times
d7bb0b2
1 year ago
Sorry only b, CAUSE A [1] must be [0]
upvoted 1 times
d7bb0b2
1 year ago
and A missing }
upvoted 1 times
...
...
...
Omnisumem
1 year, 4 months ago
Selected Answer: B
Tested: B.
upvoted 1 times
...
Stavok
1 year, 6 months ago
Selected Answer: B
B is correct
upvoted 1 times
...
tmuralimanohar
1 year, 7 months ago
Answer:B
upvoted 1 times
...
Mukes877
1 year, 8 months ago
Selected Answer: B
B is correct Because Static is for not creating any object and values()[1] gives -> B
upvoted 1 times
...
Obalt
1 year, 12 months ago
Correct answer is B
upvoted 1 times
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...
exam
Someone Bought Contributor Access for:
SY0-701
London, 1 minute ago