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
'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
...
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, 4 months agovic88
Most Recent 3 months, 3 weeks agoswgreen
4 months, 3 weeks agoarjunrawatirissoftware
1 year, 3 months agoDarGrin
1 year, 3 months agoOndo
1 year, 4 months agogg7495
1 year, 4 months agoVicky_65
1 year, 9 months agoAnkit1010
1 year, 11 months agohaisaco
2 years ago