Interface in Java - Simple Ga Nerchukundam
Welcome to LearnTechSoft | Java Course in Telugu | By Praneel
Ippudu: OOPs lo chala important concept Interface gurinchi nerchukundam.
1. Interface Ante Enti?
Simple ga cheppalante, Interface ante oka Rule Book lanti dhi.
Andulo em cheyyalo matrame untundi, ela cheyyalo undadhu. Danini use chese class, aa panini ela cheyyalo cheppali.
Example: Remote lo buttons untayi, kani andulo current ela vasthundo manaki theliyadhu. Manam button press chestham, pani avuthundi. Ade Interface.
2. Example Tho Ardham Chesukundam
Manam oka Vehicle ane Interface theesukundam. Andulo start() ane rule undhi. Car class danini ela start cheyyalo chepthundi, Bike class danini vere la chepthundi.
interface Vehicle {
void start(); // rule matrame, body ledhu
}
class Car implements Vehicle {
public void start() {
System.out.println("Car started with key");
}
}
class Bike implements Vehicle {
public void start() {
System.out.println("Bike started with kick");
}
}
public class Main {
public static void main(String[] args) {
Vehicle v1 = new Car();
v1.start();
Vehicle v2 = new Bike();
v2.start();
}
}
3. Interface Valla Use Enti?
- 1. 100% Abstraction: Emi cheyyalo matrame chepthundi.
- 2. Multiple Inheritance: Java lo oka class okate class ni extend cheyagalam, kani chala Interfaces ni implements cheyochu.
- 3. Loose Coupling: Code ni easy ga marchachu, anni chotla thirigi rayakkarledu.
Abstract Class vs Interface - Chinna Difference
Abstract Class - Konni methods ready ga untayi, konni rules ga untayi.
Interface - Anni methods rules ga matrame untayi. Body undadhu.
Interview lo ee difference thappakunda adugutharu, gurthu pettukondi.
4. Conclusion
Interface ante bayapadakandi. Adhi manam andaram roju vadhe Remote, Switch lanti dhi. Java lo manchi project cheyyali ante Interface thappakunda ravali. Ee example ni 2 sarlu practice cheyyandi.
Next Post: Next post lo manam Polymorphism vs Inheritance - Real Life Examples inka deep ga nerchukundam. Miss avvakunda LearnTechSoft ni follow avvandi.
© LearnTechSoft - Java in Telugu
No comments:
Post a Comment