Abstraction in Java with example
For Video : CLICK HERE
If a class contain any abstract method then the class is declared as abstract class.
An abstract class is never instantiated. It is used to provide abstraction, although it does not provide 100% abstraction because it can also have concrete method.
Java Abstract classes are used to declare common characteristics of subclasses, It can only be used as a superclass for other classes that extend the abstract class.
Abstraction Example :
abstract class Chandan
int z =10;
abstract public int sum(int x, int y);
abstract public int sub(int x, int y);
public class Abstract extends Chandan
public int sum(int x, int y)
public int sub(int x, int y)
public static void main(String args)
int x = 20;
int z = 30;
Abstract obj = new Abstract();
System.out.println("your sum is :" +obj.sum(4,7));
System.out.println("your subtraction is :" +obj.sub(4,7));
your sum is :11
your subtraction is :-3