Abstract class or methods example-3

This motive of this code is to show that an abstract class can hold abstract and non abstract classes

 
 

Share on Google+Share on Google+

Abstract class or methods example-3

Ads

This motive of this code is to show that an abstract class can hold abstract and non abstract classes
abstract class BaseAbstractClass {
  abstract void baseMethod1()
  // Definition done in DerivedClass class

  void baseMethod2() {
    System.out
    .println("baseMethod2() method called form BaseAbstractClass");
  }
}

class DerivedClass extends BaseAbstractClass {
  void baseMethod1() {
  System.out
  .println("Defining the defination of abstract method baseMethod1()");
  }
}

class AbstractExample2 {
  public static void main(String[] args) {
    DerivedClass b = new DerivedClass();
    b.baseMethod1();
    b.baseMethod2();
  }
}

/*
 * Defining the definition of abstract method baseMethod1()
 * baseMethod2() method called form BaseAbstractClass
*/

Advertisements

Ads

Posted on: July 1, 2010 If you enjoyed this post then why not add us on Google+? Add us to your Circles