Video 48(ch10)

Yash
0

 




Program:-


class A{
    public int a;
    public int harry(){
        return 4;
    }
    public void Method2(){
        System.out.println("I am method 2 form class A");
    }
}

class B extends A{
    @Override //this is used here because sometimes we think we override the method but it does not so to remind that we use the @Override.
    public void Method2(){
        System.out.println("I am method 2 form class B");
    }
    public void Method3(){
        System.out.println("Iam method 3 from class B");
    }
}

public class MethodOverridingV48 {
    public static void main(String[] args) {
        A a = new A();
        a.Method2();

        B b = new B();
        b.Method2();
    }
}

Post a Comment

0 Comments
Post a Comment (0)
To Top