Java

What is an abstraction?

What is an abstraction?

In object oriented programming language abstraction is concept where function or variable declare but not define and can’t create an instance. If you want to use you must be extend the class.

In java abstract methods or functions don’t have the body, only declaration.

An abstract class is declare with the keyword abstract or by nature. An abstract class must have atleast one abstract methods.

An abstract class methods are declare with in subclass or chiled class.

An abstract class is a concept in java which is incomplete and you can’t create an instance.

 

Example

abstract class A{

abstract void students();

public void teacher()

{

System.out.println(“Teacher is teaching java”);

}

}

class B extends A{

void students ()

{

System.out.println(“Students are studying java..”);

}

public static void main(String args[]){

A objA = new A();

objA.students();

objA. teacher ();

}

}

Leave a Reply

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