Correct is BF.
public class App {
public static void main(String[] args) {
Employee employee = new Employee();
Employee manager = new Manager();
Employee director = new Director();
director.stockOptions = 1_000;
employee.salary = 50_000;
manager.budget = 1_000_000;
manager.stockOption = 500;
employee.budget = 200_000;
director.salary = 80_000;
}
}
class Employee {
public int salary;
}
class Manager extends Employee {
public int budget;
}
class Director extends Manager {
public int stockOptions;
}
The answer is DE, why?
Because apparently the question is wrong, the question should be which of those DONT compile, because ABCF work fine, those who answered only BF might have problems later with similar questions..
BF are correct.
1. The type of the object determines which properties exist within the object in memory.
2. The type of the reference to the object determines which methods and variables are
accessible to the Java program.
class Employee{
public int salary;
}
class Manager extends Employee{
public int budget;
}
public class Director extends Manager{
public int stockOptions;
public static void main(String[] args) {
Employee employee = new Employee();
Employee manager = new Manager();
Employee director = new Director();
// director.stockOptions = 1_000; // Compilation Error
employee.salary = 50_000;
// manager.budget = 1_000_000; // Compilation Error
// manager.stockOption = 500; // Compilation Error
// employee.budget = 200_000; // Compilation Error
director.salary = 80_000;
}
}
The answer is
BF but this is a tricky question as it involves inheritance and polymorphism. But you can make it less complicated if we eliminate the wrong ones:
-> Let's start with the letter B, she is evidently right, because "Employee" is the parent class and the method is hers, so we already have a right alternative.
-> We are already sure that the letter B is the first correct one, when looking at the code, we realize that all objects are a variable of type "Employee", that is, they can access anything public of the "Employee" class without problems , and the only answer we have with that is the letter F.
It is my fault that I overlooked the type of manager and director. The right answer should be B and F.
upvoted 1 times
...
...
...
This section is not available anymore. Please use the main Exam Page.1z0-808 Exam Questions
Log in to ExamTopics
Sign in:
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.
Upvoting a comment with a selected answer will also increase the vote count towards that answer by one.
So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.
MPignaProTech
7 months, 2 weeks agodiptimayee
7 months, 3 weeks agoSisar
9 months, 1 week ago7df49fb
1 year, 2 months agoyanoolthecool
1 year, 5 months agoUAK94
2 years, 7 months agoiSnover
2 years, 8 months agoalex_au
2 years, 8 months agoalex_au
2 years, 8 months ago