KEMBAR78
OOP_Java_Part2.pptxOOP_Java_Part1OOP_Java_Part1 | PPTX
Title Slide
• Mastering OOP in Java – Part 2
• Presented by: [Your Name]
• Institution: [Your Institution]
• Date
Inheritance
• Reuse class features using extends.
• Example:
• class Dog extends Animal { ... }
Method Overriding
• Redefine superclass method in subclass.
• Use @Override annotation.
Polymorphism
• Compile-time: Method Overloading.
• Runtime: Method Overriding.
• Example:
• int add(int a, int b); double add(double a,
double b);
Abstraction
• Abstract class: Partially implemented.
• Interface: Fully abstract.
• Example:
• abstract class Shape { abstract void draw(); }
Interface vs Abstract Class
• Abstract Class: Can have state.
• Interface: Only constants and abstract
methods.
• Interfaces allow multiple inheritance.
Case Study: Shape Class
• abstract class Shape { abstract void area(); }
• Rectangle, Circle extend Shape and implement
area().
Java Keywords in OOP
• this: Refers to current object.
• super: Refers to parent class.
• final: Prevents override.
• static: Shared across instances.
Best Practices in OOP
• Use private fields and public methods.
• Prefer composition over inheritance.
• Avoid repetition (DRY principle).
Summary and Activity
• Create abstract class Employee.
• Subclasses: Manager, Developer.
• Override displayDetails().

OOP_Java_Part2.pptxOOP_Java_Part1OOP_Java_Part1

  • 1.
    Title Slide • MasteringOOP in Java – Part 2 • Presented by: [Your Name] • Institution: [Your Institution] • Date
  • 2.
    Inheritance • Reuse classfeatures using extends. • Example: • class Dog extends Animal { ... }
  • 3.
    Method Overriding • Redefinesuperclass method in subclass. • Use @Override annotation.
  • 4.
    Polymorphism • Compile-time: MethodOverloading. • Runtime: Method Overriding. • Example: • int add(int a, int b); double add(double a, double b);
  • 5.
    Abstraction • Abstract class:Partially implemented. • Interface: Fully abstract. • Example: • abstract class Shape { abstract void draw(); }
  • 6.
    Interface vs AbstractClass • Abstract Class: Can have state. • Interface: Only constants and abstract methods. • Interfaces allow multiple inheritance.
  • 7.
    Case Study: ShapeClass • abstract class Shape { abstract void area(); } • Rectangle, Circle extend Shape and implement area().
  • 8.
    Java Keywords inOOP • this: Refers to current object. • super: Refers to parent class. • final: Prevents override. • static: Shared across instances.
  • 9.
    Best Practices inOOP • Use private fields and public methods. • Prefer composition over inheritance. • Avoid repetition (DRY principle).
  • 10.
    Summary and Activity •Create abstract class Employee. • Subclasses: Manager, Developer. • Override displayDetails().