Oracle
1Z0-851 · Question #256
1Z0-851 Question #256: Real Exam Question with Answer & Explanation
Sign in or unlock 1Z0-851 to reveal the answer and full explanation for question #256. The question stem and answer options stay visible for context.
Question
Given: public class Rainbow { public enum MyColor { RED(0xff0000), GREEN(0x00ff00), BLUE(0x0000ff); private final int rgb; MyColor(int rgb) { this.rgb = rgb; } public int getRGB() { return rgb; } }; public static void main(String[] args) { // insert code here } } Which code fragment, inserted at line 19, allows the Rainbow class to compile?
Options
- AMyColor skyColor = BLUE;
- BMyColor treeColor = MyColor.GREEN;
- Cif(RED.getRGB() < BLUE.getRGB()) { }
- DCompilation fails due to other error(s) in the code.
- EMyColor purple = new MyColor(0xff00ff);
- FMyColor purple = MyColor.BLUE + MyColor.RED;
Unlock 1Z0-851 to see the answer
You've previewed enough free 1Z0-851 questions. Unlock 1Z0-851 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.