Home Tutorial Java Certification Abstract class or methods example-3

 
 

Abstract class or methods example-3
Posted on: July 1, 2010 at 12:00 AM
Advertisement
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
*/
Advertisement

Related Tags for Abstract class or methods example-3:


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: July 1, 2010

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com