Title Slide • Understanding Object-Oriented Programming in Java – Part 1 • Presented by: [Your Name] • Institution: [Your Institution] • Date
What is OOP? • Object-Oriented Programming (OOP) is a paradigm based on objects. • Real-world analogy: Car, Bank Account, Library Book. • Goal: Reusable and scalable components.
Principles of OOP • Encapsulation: Wrapping data and code into one unit. • Inheritance: Derive new classes from existing ones. • Polymorphism: One interface, many implementations. • Abstraction: Hide internal details.
Class and Object in Java • Class: Blueprint of an object. • Object: Instance of a class. • Example: • class Car { • int speed = 0; • void accelerate() { • speed += 10; • } • }
Encapsulation • Protects data from unauthorized access. • Use of private variables and public get/set methods. • Example: • class Student { • private int rollNo; • public void setRollNo(int r) { rollNo = r; } • public int getRollNo() { return rollNo; } • }
Access Modifiers • public: Visible everywhere. • private: Within class only. • protected: Package & subclass. • default: Within package only.
Constructors in Java • Called when object is created. • Can be overloaded. • Example: • class Book { • Book(String t) { title = t; } • }
Case Study: Bank Account • Encapsulation and methods. • Example: • class BankAccount { • private double balance; • public void deposit(double amt) {...} • }
Summary • OOP simplifies design. • Key concepts: Class, Object, Encapsulation. • Practice helps understanding.
Q&A / Activity • Create class: Library with bookId, title. • Set and get data using methods.

OOP_Java_Part1OOP_Java_Part1OOP_Java_Part1.pptx

  • 1.
    Title Slide • UnderstandingObject-Oriented Programming in Java – Part 1 • Presented by: [Your Name] • Institution: [Your Institution] • Date
  • 2.
    What is OOP? •Object-Oriented Programming (OOP) is a paradigm based on objects. • Real-world analogy: Car, Bank Account, Library Book. • Goal: Reusable and scalable components.
  • 3.
    Principles of OOP •Encapsulation: Wrapping data and code into one unit. • Inheritance: Derive new classes from existing ones. • Polymorphism: One interface, many implementations. • Abstraction: Hide internal details.
  • 4.
    Class and Objectin Java • Class: Blueprint of an object. • Object: Instance of a class. • Example: • class Car { • int speed = 0; • void accelerate() { • speed += 10; • } • }
  • 5.
    Encapsulation • Protects datafrom unauthorized access. • Use of private variables and public get/set methods. • Example: • class Student { • private int rollNo; • public void setRollNo(int r) { rollNo = r; } • public int getRollNo() { return rollNo; } • }
  • 6.
    Access Modifiers • public:Visible everywhere. • private: Within class only. • protected: Package & subclass. • default: Within package only.
  • 7.
    Constructors in Java •Called when object is created. • Can be overloaded. • Example: • class Book { • Book(String t) { title = t; } • }
  • 8.
    Case Study: BankAccount • Encapsulation and methods. • Example: • class BankAccount { • private double balance; • public void deposit(double amt) {...} • }
  • 9.
    Summary • OOP simplifiesdesign. • Key concepts: Class, Object, Encapsulation. • Practice helps understanding.
  • 10.
    Q&A / Activity •Create class: Library with bookId, title. • Set and get data using methods.