Multiple choice technology programming languages

class P { public void doIt() {} } class C extends P { private void doIt() {}} It is not legal.

  1. True

  2. False

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

You cannot reduce visibility when overriding - private is more restrictive than public. Java's overriding rules require the subclass method to have at least the same access level as the parent. Changing public void doIt() to private void doIt() violates this, so the code is illegal.