Q.– Given:-
public class Employee {
public int salary;
}
public class Manager extends Employee {
public int budget;
}
public class Director extends Manager {
public int stockOptions;
}
And given this main method:
public static void main(String[ ] args) {
Employee employee = new Employee();
Employee manager = new Manager();
Employee director = new Director();
//line n1
}
Which two options compile when placed at line n1 of the main method?
A) director.stockOptions = 1_000;
B) director.salary = 80_000;
C) employee.budget = 200_000;
D) manager.budget = 1_000_000;
E) employee.salary = 50_000;
F) manager.stockOptions = 500;
⧪ please give your answer in a comment section.
public class Employee {
public int salary;
}
public class Manager extends Employee {
public int budget;
}
public class Director extends Manager {
public int stockOptions;
}
And given this main method:
public static void main(String[ ] args) {
Employee employee = new Employee();
Employee manager = new Manager();
Employee director = new Director();
//line n1
}
Which two options compile when placed at line n1 of the main method?
A) director.stockOptions = 1_000;
B) director.salary = 80_000;
C) employee.budget = 200_000;
D) manager.budget = 1_000_000;
E) employee.salary = 50_000;
F) manager.stockOptions = 500;
⧪ please give your answer in a comment section.
8 Comments
Option C F
ReplyDeleteC F
ReplyDeleteD E
ReplyDeleteC) employee.budget = 200_000;
ReplyDeleteF) manager.stockOptions = 500;
A D
ReplyDeleteB E
ReplyDeleteB E
ReplyDeleteBE variable resolution concepts/ base on reference not object type
ReplyDelete