exam questions

Exam 1z0-809 All Questions

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

Exam 1z0-809 topic 1 question 9 discussion

Actual exam question from Oracle's 1z0-809
Question #: 15
Topic #: 2
[All 1z0-809 Questions]

Given:
public enum USCurrency {
PENNY (1),
NICKLE(5),
DIME (10),
QUARTER(25);
private int value;
public USCurrency(int value) {
this.value = value;
}
public int getValue() {return value;}
}
public class Coin {
public static void main (String[] args) {
USCurrency usCoin =new USCurrency.DIME;
System.out.println(usCoin.getValue()):
}
}
Which two modifications enable the given code to compile?
USCurrency enumeration declaration within the Coin class.

  • A. Nest the USCurrency enumeration constructor private.
  • B. Make the new keyword from the instantion of usCoin.
  • C. Remove the value as a static method.
  • D. Make the getter method of final keyword in the declaration of value.
  • E. Add the
Show Suggested Answer Hide Answer
Suggested Answer: AE 🗳️

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
Innovation
12 months ago
remove the new keyword and the constructor should be private or default, but not public or protected because we can't create new instances outside of the enum
upvoted 3 times
...
Ritesh_
1 year, 2 months ago
B. Make the USCurrency enumeration constructor private. C. Remove the new keyword from the instantion of usCoin.
upvoted 3 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 ...