Tuesday , December 6 2016
Home / JAVA / Abstract class and abstract method in Java

Abstract class and abstract method in Java

This tutorial is to tell you about the abstract class and the abstract method in Java 

Abstract Class :- A class which cannot be instantiated i.e object cannot be created only is called Abstract class.

In other words ,we can say that only we can inherit the abstract class but we cannot create the object of this class to execute the functions.In abstract class we can have the abstract methods as well as simple methods but cannot execute those methods in the abstract class itself.For this we have to inherit the abstract class in the simple class for execution of the methods.

Abstract Method :- An abstract method is a method in the abstract class which is not defined in the abstract class.Only the declaration of the functions are defined and end the declaration by semicolon.

And than define  the abstract method implementation after inherit the abstract class in the simple class.Implementation of the abstract methods are compulsory in the derived class.

*1  – Defining the class abstract which means it can be inherited but cannot be instantiated i.e object cannot be created for the abstract class.We need to inherit this abstract class and use it for the execution of the methods.

*2  – Abstract methods are not implemented in abstract class,they are only defined and than implemented after inheriting the abstract class and than defining the methods in the derived class and execute them after creating the objects in the child class.

*3  – Inheriting the abstract class and than implements all the abstract methods and than execute them using the objects.

OUTPUT:

 

 

abstract class abstract method

Also See:   Java Program to find Anagrams Words

Check Also

Program for Matrix Multiplication in JAVA

Matrix Multiplication:– Here is given a Java Program for Matrix Multiplication also call matrix product. In ...

Leave a Reply

Your email address will not be published. Required fields are marked *

Preventing spam * Time limit is exhausted. Please reload the CAPTCHA.