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, 4 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
...
vic88
Most Recent 3 months, 3 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
4 months, 3 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, 3 months ago
Answer C, D
upvoted 1 times
...
DarGrin
1 year, 3 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, 4 months ago
réponse A et E
upvoted 1 times
...
gg7495
1 year, 4 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
1 year, 9 months 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
1 year, 11 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 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