exam questions

Exam 1z0-809 All Questions

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

Exam 1z0-809 topic 1 question 27 discussion

Actual exam question from Oracle's 1z0-809
Question #: 27
Topic #: 1
[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? (Choose two.)

  • A. Nest the USCurrency enumeration declaration within the Coin class.
  • B. Make the USCurrency enumeration constructor public.
  • C. Remove the new keyword from the instantion of usCoin.
  • D. Make the getValue() method public.
  • E. Add the final keyword in the declaration of value.
Show Suggested Answer Hide Answer
Suggested Answer: BC 🗳️

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
maslac
Highly Voted 3 years, 4 months ago
B&C are correct, only in answer B it should say private, not public. B. Make the USCurrency enumeration constructor private.
upvoted 14 times
...
asdfjhfgjuaDCV
Most Recent 4 months, 4 weeks ago
B&C are correct, only in answer B it should say private, not public. B. Make the USCurrency enumeration constructor private.
upvoted 1 times
...
steefaand
5 months, 4 weeks ago
Selected Answer: BC
B and C are correct. Just typo in answer, constructor must be (package) private. Also new isn't used when creating enum values.
upvoted 1 times
...
r1muka5
1 year, 5 months ago
Correct Answers are B&C
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