Oracle
1Z0-809 · Question #196
1Z0-809 Question #196: Real Exam Question with Answer & Explanation
Sign in or unlock 1Z0-809 to reveal the answer and full explanation for question #196. The question stem and answer options stay visible for context.
Question
Given the code fragment:
for (Course a : Course.values()) {
System.out.print(a + " Fees " + a.getCost() + " ");
}
Which is the valid definition of the Course enum?
Options
- Aenum Course { JAVA(100), J2ME(150); private int cost; public Course(int c) { this.cost = c; } int getCost() { return cost; } }
- Benum Course { JAVA(100), J2ME(150); private static int cost; private Course(int c) { this.cost = c; } static int getCost() { return cost; } }
Unlock 1Z0-809 to see the answer
You've previewed enough free 1Z0-809 questions. Unlock 1Z0-809 for full answers, explanations, the timed quiz mode, progress tracking, and the master PDF. Question stem and options stay visible so you can still see what's on the exam.