Java Abstraction
It is a procedure of hiding implementation details together with showing exclusively functionality to the user.
In coffee nosotros accept 2 types of methods
i) Concrete methods (The methods which are having body)
Example:
public void add(){
Statements
---------
--------
---------
}
ii) Abstract methods (The methods which are non having body)
Ex:
public void add();
-------------------------------------------------
if nosotros know the method name, simply don't know the method functionality, together with then nosotros become for abstract methods.
> Java Class contains 100% concrete methods
> Abstract Class contains ane or to a greater extent than abstract methods.
Example:
Class 1 (having 10 methods)
(10 methods are concrete methods)
It is a Java Class
-------------------------
Class 2 (having 10 methods)
(5 concrete Methods together with five abstract methods)
Abstract class
Class three (having 10 methods)
(10 methods are Abstract methods)
Abstract class
----------------------------------
public bird HeroHonda extends Bike {
@Override
populace void handle() {
System.out.println("Bikes accept handle");
}
@Override
populace void seat() {
System.out.println("Bikes accept Seat");
}
populace static void original (String [] args){
HeroHonda obj = novel HeroHonda();
obj.handle();
obj.engine();
obj.seat();
}
-------------------------------------------
Interfaces inwards Java
> Interface is a Java type Definition block which is 100% abstract.
> All the Interface methods are yesteryear default populace together with abstract.
> Static together with concluding modifiers are non allowed for interface methods.
> In Interfaces variables accept to initialize at the fourth dimension of declaration.
Example:
int a; // Incorrect
int a = 10; // Correct
> In interfaces variables are populace static concluding yesteryear default.
> Interface is going to locomote used using "implements" keyword.
--------------------------------------------
Example:
public bird Example2 implements Example1{
@Override
populace void add() {
System.out.println("Addition");
}
@Override
populace void sub() {
System.out.println("Subtraction");
}
public static void original (String [] args){
Example2 abc = novel Example2();
abc.add();
abc.sub();
}
}
--------------------------------------------------------
From Class (Concrete Class or Abstract Class) to Class nosotros usage "extends" keyword
i) From Concrete Class to Sub bird - nosotros tin access Super bird methods directly.
ii) From Abstract Class to Sub bird - Implement all abstract methods together with then nosotros tin access all methods.
----------------------------------------------
From Interface to Class nosotros usage "implements" keyword
From Interface to Class - Implement all methods together with access.
------------------------------------------------------------------
Sumber http://www.gcreddy.com/
It is a procedure of hiding implementation details together with showing exclusively functionality to the user.
In coffee nosotros accept 2 types of methods
i) Concrete methods (The methods which are having body)
Example:
public void add(){
Statements
---------
--------
---------
}
ii) Abstract methods (The methods which are non having body)
Ex:
public void add();
-------------------------------------------------
if nosotros know the method name, simply don't know the method functionality, together with then nosotros become for abstract methods.
> Java Class contains 100% concrete methods
> Abstract Class contains ane or to a greater extent than abstract methods.
Example:
Class 1 (having 10 methods)
(10 methods are concrete methods)
It is a Java Class
-------------------------
Class 2 (having 10 methods)
(5 concrete Methods together with five abstract methods)
Abstract class
Class three (having 10 methods)
(10 methods are Abstract methods)
Abstract class
----------------------------------
public bird HeroHonda extends Bike {
@Override
populace void handle() {
System.out.println("Bikes accept handle");
}
@Override
populace void seat() {
System.out.println("Bikes accept Seat");
}
populace static void original (String [] args){
HeroHonda obj = novel HeroHonda();
obj.handle();
obj.engine();
obj.seat();
}
-------------------------------------------
Interfaces inwards Java
> Interface is a Java type Definition block which is 100% abstract.
> All the Interface methods are yesteryear default populace together with abstract.
> Static together with concluding modifiers are non allowed for interface methods.
> In Interfaces variables accept to initialize at the fourth dimension of declaration.
Example:
int a; // Incorrect
int a = 10; // Correct
> In interfaces variables are populace static concluding yesteryear default.
> Interface is going to locomote used using "implements" keyword.
--------------------------------------------
Example:
public bird Example2 implements Example1{
@Override
populace void add() {
System.out.println("Addition");
}
@Override
populace void sub() {
System.out.println("Subtraction");
}
public static void original (String [] args){
Example2 abc = novel Example2();
abc.add();
abc.sub();
}
}
--------------------------------------------------------
From Class (Concrete Class or Abstract Class) to Class nosotros usage "extends" keyword
i) From Concrete Class to Sub bird - nosotros tin access Super bird methods directly.
ii) From Abstract Class to Sub bird - Implement all abstract methods together with then nosotros tin access all methods.
----------------------------------------------
From Interface to Class nosotros usage "implements" keyword
From Interface to Class - Implement all methods together with access.
------------------------------------------------------------------