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
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.
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
'revolve()' in 'Earth' clashes with 'revolve()' in 'Planet'; attempting to assign weaker access privileges ('package-private'); was 'protected'. Change revolve() public or protected.
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
}
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.
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.
CE. protected line 4 can be change to public.
D: protected = protected
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.
Ancient1
Highly Voted 2 years, 7 months agoKarreRavi
Most Recent 1 month agoEsau11
1 month, 3 weeks agoEsau11
1 month, 3 weeks agojp_ofi
2 months, 3 weeks agovic88
6 months, 2 weeks agoswgreen
7 months, 2 weeks agoarjunrawatirissoftware
1 year, 6 months agoDarGrin
1 year, 6 months agoOndo
1 year, 6 months agogg7495
1 year, 6 months agoVicky_65
2 years agoAnkit1010
2 years, 2 months agohaisaco
2 years, 3 months ago