Abstract Class In Java Example

Chapter: Inheritance Last Updated: 20-07-2016 03:27:49 UTC

Program:

            /* ............... START ............... */
                
abstract class A {
	abstract void callme();
}

public class JavaAbstractClassExample extends A {

	void callme() {
		System.out.println("this is callme.");
	}

	public static void main(String[] args) {
		JavaAbstractClassExample b = new JavaAbstractClassExample();
		b.callme();
	}
}
                /* ............... END ............... */
        

Output

this is callme.

Notes:

  • A class that is declared with abstract keyword, is known as abstract class in java. It can have abstract and non-abstract methods (method with body).
  • Abstraction is a process of hiding the implementation details and showing only functionality to the user.
  • A class which contains the abstract keyword in its declaration is known as abstract class.
  • Abstract classes may or may not contain abstract methods.
  • If a class is declared abstract it cannot be instantiated.
  • To use an abstract class you have to inherit it from another class, provide implementations to the abstract methods in it.
  • If you inherit an abstract class you have to provide implementations to all the abstract methods in it.

Tags

Abstract Class, Java

Similar Programs Chapter Last Updated
Java Final Class Inheritance 02-08-2017
Java Final Method In Inheritance Inheritance 02-08-2017
Java Multilevel Hierarchical Inheritance Inheritance 01-08-2017
Java Super To Invoke Parent Class Method Inheritance 31-07-2017
Java Super To Invoke Parent Class Constructor Inheritance 30-07-2017
Static And Dynamic Binding In Java Inheritance 24-03-2017
Java Overloaded Method To Print Array Inheritance 03-09-2016
Dynamic Method Dispatch In Java Example Inheritance 19-06-2016
Method Overriding In Java Example Inheritance 20-07-2016
Method Overloading In Java Example Inheritance 20-07-2016
Inheritance And Constructors In Java Inheritance 20-07-2016
Multilevel Inheritance In Java Example Inheritance 22-09-2018
Super() In Java Example Inheritance 14-07-2016
Inheritance In Java Example Inheritance 20-07-2016

1