Abstract Practice Program 3

Abstract Practice Program 3

Program
abstract class A
{
    abstract void show();
    void disp()
    {
        System.out.println("This is abstract disp Method");
    }
}
class B extends A
{
    void show()
    {
        System.out.println("welcome");
    }
    void add()
    {
        System.out.println("This is B class Add Method");
    }
}
class C extends A
{
    void show()
    {
        System.out.println("java");
    }
}
public class Main
{
    public static void main(String arhs[])
    {
        A a=new B();
        a.show();
        a.disp();
        a.add();
    }
}

Output:

Main.java:30: error: cannot find symbol
a.add();
}
^ symbol: method add()
location: variable a of type A
1 error
Note:
We can't call child class own methods by using abstract class object


Abstract In Java



More Questions


140 . Abstract Practice Program 2
141 . Abstract Practice Program 3
142 . Abstract Practice Program 4
143 . Abstract Practice Program 5
144 . Down Casting Program
145 . Write a Java-program using super.(dot)
146 . Write a Java-program with out using super() no parameterized
147 . Write a Java-program with out using super() with parameterized
148 . Write a Java-program with using polymorphism
149 . Write a Java-program using static method overloading
150 . Write a Java-program using dynamic method overloading