Oracle
1Z0-803 · Question #162
1Z0-803 Question #162: Real Exam Question with Answer & Explanation
The correct answer is D: line n4. See the full explanation below for the reasoning.
Question
Given: public class VarScope { public static void main (Stirng[] args) { String color = "red"; int qty = 10; if (color.equals("red")) { // line n1 int amount = qty * 10; } else if (color.equals("green")) { int amount = qty * 15; // line n2 } else if (color.equals("blue")) { int amount = qty * 5; // line n3 } System.out.print(amount); // line n4 } } Which line causes a compilation error?
Options
- Aline n1
- Bline n2
- Cline n3
- Dline n4
Community Discussion
No community discussion yet for this question.