What happens as a result of the following code execution?

public class Test {
    class A {
        private void act(){};
    class B extends A {
        protected void act(){};
    class C extends B {
        public void act(){};
    class D extends B {
        void act(){};
    public static void main(String[] args){
        A obj = new Test().new D();
Visibility of method, declared without modifiers, is less than visibility of public method. The subclass can not cut back the visibility of overridden method of an ancestor class.

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback
Keep exploring
Java quizzes
Sign Up Now
or Subscribe for future quizzes