Oracle
1Z0-851 · Question #156
1Z0-851 Question #156: Real Exam Question with Answer & Explanation
Sign in or unlock 1Z0-851 to reveal the answer and full explanation for question #156. The question stem and answer options stay visible for context.
Question
Given: 11. public class Rainbow { 12. public enum MyColor { 13. RED(0xff0000), GREEN(0x00ff00), BLUE(0x0000ff); 14. private final int rgb; 15. MyColor(int rgb) { this.rgb = rgb; } 16. public int getRGB() { return rgb; } 17. }; 18. public static void main(String[] args) { 19. // insert code here 20. } 21. } 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.