logo
Java Abstract
Abstraction :
Hiding the internal implementation and highlighting the set of services that process is called abstraction.
Ex :
a. Bank ATM Screens (Hiding thee internal implementation and highlighting set of services like withdraw, money transfer, mobile registration).
b. Mobile phones (The mobile persons are hiding the internal circuit implementation and highlighting touch screen).

Java Images
The way of representation the methods are divided into two types
1) Normal methods
2) Abstract methods
Normal methods:-
Normal method is a method which contains declaration as well as implementation.
Ex:-
Void m1()
{
---------
--------body;
---------

Abstract methods :
The method which is having declaration but not implementations such type of methods are called abstract Method. Hence every abstract method should end with ;
The child classes are responsible to provide implementation for parent class abstract methods.
Ex:  void m1 (); ----------abstract method
Based on above representation of methods the classes are devided into two types
Based on above representation of methods the classes are devided into two types
1) Normal classes
2) Abstract classes
Normal classes:-
Normal class is a java class it contains only normal methods. 

Abstract class :
Abstract class is a jav class which contains at least one abstract method.
To specify the particular class is abstract and particular method is abstract method to the compiler use abstract modifier.
For the abstract classes it is not possible to create an object. Because it contains the unimplemented methods.
For any class if we don’t want instantiation then we have to declare that class as abstract i.e., for abstract classes instantiation (creation of object) is not possible.

Normal class:
class Test
{
void m1()
{
body;
}
void m2()
{
body;
}
void m3()
{
body
}
}

Abstract class:
Abstract class Test
{
void m1() { body; }
void m2() { body; }
Abstract void m3();
}
Abstract class:-
class Test
{
Abstract void m1();
Abstract void m2();
Abstract void m3();
}
The abstract class contains abstract methods for that abstract methods provide the implementation in child classes.
abstract class Test 
{ 
abstract void m1(); 
abstract void m2(); 
abstract void m3(); 
} 
class AbstractDemo extends Test 
{ 
void m1() 
{ 
System.out.println("m1-method"); 
} 
void m2()
{ 
System.out.println("m2-method"); 
} 
void m3() 
{ 
System.out.println("m3-method"); 
} 
public static void main(String[] args) 
{ 
AbstractDemo ad=new AbstractDemo(); 
ad.m1(); 
ad.m2(); 
ad.m3(); 
} 
}
Output :
output:
m1-method,m2-method,m3-method
if the child class is unable to provide the implementation for parent class abstract methods at that situation we can declare that class is an abstract then take one more child class in that class provide the implementation for remaining methods.
abstract class Test 
{ 
abstract void m1(); 
abstract void m2(); 
abstract void m3(); 
} 
abstract class AbstractDemo1 extends Test 
{ 
void m1() 
{ 
System.out.println("m1-method"); 
} 
void m2() 
{ 
System.out.println("m2-method"); 
} 
}; 
class AbstractDemo extends AbstractDemo1 
{ 
void m3() 
{ 
System.out.println("m3-method"); 
} 
public static void main(String[] args) 
{ 
AbstractDemo ad=new AbstractDemo(); 
ad.m1(); 
ad.m2(); 
ad.m3();
}
}
Output :
output:m1-method,,m2-method,,m3-method
for the abstract methods it is possible to provide any type of return type(void, int, char,Boolean…..)
abstract class Test1 
{ 
abstract int m1(); 
abstract boolean m2(); 
} 
class Test2 extends Test1 
{ 
int m1() 
{ 
return 100; 
} 
boolean m2() 
{ 
return true; 
} 
public static void main(String[] args) 
{ 
Test2 t=new Test2(); 
int a=t.m1(); 
System.out.println(a); 
boolean b=t.m2(); 
System.out.println(b); 
} 
};
Output :
output:100,true
Note:-
The abstract classes is java class it contains zero number of abstract methods.
Even though class does not contain any abstract method still we can declare the class as abstract i.e. abstract class can contain zero number of abstract methods. The abstract classes it is not possible to create object.