exam questions

Exam 1z0-808 All Questions

View all questions & answers for the 1z0-808 exam

Exam 1z0-808 topic 1 question 160 discussion

Actual exam question from Oracle's 1z0-808
Question #: 160
Topic #: 1
[All 1z0-808 Questions]

Given these classes:
and this main method:

Which two options compile when placed at line n1 of the main method? (Choose two.)

  • A. director.stockOptions = 1_000;
  • B. employee.salary = 50_000;
  • C. manager.budget = 1_000_000;
  • D. manager.stockOption = 500;
  • E. employee.budget = 200_000;
  • F. director.salary = 80_000;
Show Suggested Answer Hide Answer
Suggested Answer: BF 🗳️

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
MPignaProTech
7 months, 2 weeks ago
Selected Answer: BF
BF is the good answer
upvoted 1 times
...
diptimayee
7 months, 3 weeks ago
All will compile except D & E
upvoted 1 times
...
Sisar
9 months, 1 week ago
Selected Answer: BF
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; }
upvoted 1 times
...
7df49fb
1 year, 2 months ago
all compile except DE, so i guest the question normally is which two options don't compile
upvoted 1 times
...
yanoolthecool
1 year, 5 months ago
Selected Answer: DE
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..
upvoted 2 times
...
UAK94
2 years, 7 months ago
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; } }
upvoted 3 times
...
iSnover
2 years, 8 months ago
Selected Answer: BF
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.
upvoted 2 times
alex_au
2 years, 8 months ago
The original question asks for the two **wrong** options. Actually manager can access .budget and director can also access .stockOptions.
upvoted 1 times
alex_au
2 years, 8 months ago
It is my fault that I overlooked the type of manager and director. The right answer should be B and F.
upvoted 1 times
...
...
...
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.

SaveCancel
Loading ...