Oracle
1Z0-808 · Question #35
Given the following classes: public class Employee { public int salary; } public class Manager extends Employee { public int budget; } public class Director extends Manager { public int…
The correct answer is C. employee.budget = 200_000; E. manager.stockOption = 500. C. budget is not a member of class employee. E. stockOptions is not a member of class manager.
Java Class Design
Question
Given the following classes:
public class Employee {
public int salary;
}
public class Manager extends Employee {
public int budget;
}
public class Director extends Manager {
public int stockOptions;
}
And given the following main method:
public static void main(String[] args) {
Employee employee = new Employee();
Manager manager = new Manager();
Director director = new Director();
//line n1
}
Which two options fail to compile when placed at line n1 of the main method?
Options
- Aemployee.salary = 50_000;
- Bdirector.salary = 80_000;
- Cemployee.budget = 200_000;
- Dmanager.budget = 1_000_000;
- Emanager.stockOption = 500;
- Fdirector.stockOptions = 1_000;
How the community answered
(24 responses)- B8% (2)
- C79% (19)
- D4% (1)
- F8% (2)
Explanation
C. budget is not a member of class employee. E. stockOptions is not a member of class manager.
Topics
#inheritance#field access#class hierarchy#compilation errors
Community Discussion
No community discussion yet for this question.