Sunday, February 25, 2018

Java program : Abstraction using Abstract Classes

abstract class Abstraction
{
    abstract void m1();
    abstract void m2();
    abstract void m3();
}
abstract class Child extends Abstraction
{
     void m1()
     {System.out.println("m1 implemented in child");}
     void m3()
     {System.out.println("m3 implemented in child");}
   
     /*public static void main(String[] args)
     {
        Child c= new Child();
        c.m1();
     }*/


}
class WelcomeScreen extends Child
{
        void m2()
     {System.out.println("m2 implemented in WelcomeScreen");}
     public static void main(String[] args)
     {
        WelcomeScreen hs = new WelcomeScreen();
        Abstraction a = new WelcomeScreen();
        Child c = new WelcomeScreen();
       
        //Ashutosh--------;
       
        System.out.println("Ashutosh");
        hs.m1();
        hs.m2();
        hs.m3();
       
        System.out.println("Ashutosh kumar");
        a.m1();
        a.m2();
        a.m3();
       
       
        System.out.println("Ashutosh kumar Singh");
        c.m1();
        c.m2();
        c.m3();
     }
   
}   

No comments:

Post a Comment

How can I run a C++ program directly from Windows?

How-can-I-run-a-C-program-directly-from-Windows