exam questions

Exam 1z0-808 All Questions

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

Exam 1z0-808 topic 1 question 6 discussion

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

Given the code fragment:

Which two modifications, made independently, enable the code to compile? (Choose two.)

  • A. Make the method at line n1 public.
  • B. Make the method at line n2 public.
  • C. Make the method at line n3 public.
  • D. Make the method at line n3 protected.
  • E. Make the method at line n4 public.
Show Suggested Answer Hide Answer
Suggested Answer: CD 🗳️

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
Ancient1
Highly Voted 2 years, 7 months ago
C, D Cannot reduce the visibility of the inherited method from an abstract class. In this case, can't change resolve from protected > default But you can change it to protected > protected protected > public
upvoted 8 times
...
KarreRavi
Most Recent 1 month ago
Selected Answer: AB
Answer A and B
upvoted 1 times
...
Esau11
1 month, 3 weeks ago
Selected Answer: CE
Actually, I need to revise my previous answer. The correct combination is C and E. Because: Earth's revolve() (line n3) has default access but inherits from protected access in Planet - it needs to be made at least protected (option D) or public (option C) Earth's rotate() (line n4) is implementing an abstract method with default access - it needs to be made public (option E) as it can't be more restrictive than the parent's access level Therefore my final answer is C and E - Make line n3 public and line n4 public.
upvoted 1 times
...
Esau11
1 month, 3 weeks ago
Selected Answer: DE
We need TWO modifications that would allow compilation. The valid combinations are: - D and E would work together - Making Earth's revolve() protected to match parent, and making rotate() public to be accessible. - C and E would work together - Making both Earth methods public would satisfy all access requirements. Therefore, the two modifications that would enable the code to compile are: D. Make the method at line n3 protected AND E. Make the method at line n4 public
upvoted 1 times
...
jp_ofi
2 months, 3 weeks ago
Selected Answer: D
default has more visibility than protected
upvoted 1 times
...
vic88
6 months, 2 weeks ago
'revolve()' in 'Earth' clashes with 'revolve()' in 'Planet'; attempting to assign weaker access privileges ('package-private'); was 'protected'. Change revolve() public or protected.
upvoted 1 times
...
swgreen
7 months, 2 weeks ago
Answer: C or D. Compilation Error: Cannot reduce the visibility of the inherited method from Parent. Solution: Make Earth.revolve() from default to protected/public. The order from least to most visible is: private < 'default' < protected < public. Code: abstract class Parent { protected void revolve() {} // n1 abstract void rotate(); // n2 } class Earth extends Parent { void revolve() {} // n3 protected void rotate() {} // n4 }
upvoted 1 times
...
arjunrawatirissoftware
1 year, 6 months ago
Answer C, D
upvoted 1 times
...
DarGrin
1 year, 6 months ago
I see hier 3 correct answers: C,D,E! E is ciddect too, because method rotate() can bee public. I have tested it!
upvoted 2 times
...
Ondo
1 year, 6 months ago
réponse A et E
upvoted 1 times
...
gg7495
1 year, 6 months ago
The correct answer is C and D as the overriden method in child class should be as least as accessible as the parent class method. Thus. by making it public and protected it will be more / same accessible as parent class method.
upvoted 1 times
...
Vicky_65
2 years ago
Selected Answer: CD
Because for metjod overriding the method which is overriding should be as accessible as than the overridden method
upvoted 1 times
...
Ankit1010
2 years, 2 months ago
Correct answers are C, D. We only have to make changes in //line n3 Either we have to keep it the same as protected or we can widen the scope to public. private< (default) < protected < public //line n4 is already correct because the scope was widen from (default) to protected.
upvoted 2 times
...
haisaco
2 years, 3 months ago
CE. protected line 4 can be change to public. D: protected = protected
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 ...
exam
Someone Bought Contributor Access for:
SY0-701
London, 1 minute ago