Professional Documents
Culture Documents
Java Evening Batch - Abstraction
Java Evening Batch - Abstraction
String-
Collection Framework-
Exception handling-
Encapsulation
Inheritance
Polymorphism
Abstraction---
----------------------------------------------
Abstraction-
it is process of hiding some details and showing important thing to end user
called.
Live example-
1. Car- focus out on color, size, brand, model no, seating capacity-
hiding some details means- dont know how the engine system works,
how gear system works , how sound system works
2. TV Remote-
Abstract class
Interface
-------------------------
Abstract class-
---------------------------------------------------------------
Interface-
- dont have constructor
- contain
method- public abstract by default
variable- public static final by default
- cant create the object of interface.
- Define interface-- method declare only ---->class-->implements- 1.7 java version
- I to C design principle- every class is implemented by some interfaces.
- 1.8 onwards- we write method with body interface-
- suppose if I dont want to implement or override the method then
what will you do ? make class as abstract
Note- Multple inheritance is supported in java in case of interface but not classes
Scenario based-
Interface A{
void x2 ();
}
Interface B{
void x2();
}
---------------------industry use-----------------------------
class Employee{
void getEmployeeInfo(){
//logic
}
in company,
Interface Employee{
void getEmployeeInfo();
@Override
void getEmployeeInfo(){
//logic
}
}
-------------------------------------------------
when to use abstract class and interface