Classes and Objects in Java
• Presented by: [Your Name]
• Course: [Your Course/Subject]
Introduction to OOP
• • OOP = Object-Oriented Programming
• • Focuses on real-world entities
• • Core concept: Everything is represented as
classes and objects
What is a Class?
• • Blueprint or template
• • Defines properties (variables) and behaviors
(methods)
• Example:
• class Car {
• String color;
• int speed;
• void drive() {
What is an Object?
• • Instance of a class
• • Created using 'new' keyword
• Example:
• Car myCar = new Car();
• myCar.color = "Red";
• myCar.drive();
Class vs Object
• Class → Blueprint / template
• Object → Instance of a class
• Class → Logical entity
• Object → Physical entity
• Class → Doesn’t consume memory
• Object → Consumes memory
Syntax of Class and Object
• class ClassName {
• // fields
• // methods
• }
• ClassName obj = new ClassName();
Real-life Example
• Class: MobilePhone
• • Properties: brand, model, price
• • Methods: call(), sendMessage()
• Objects:
• • Phone1 → Samsung Galaxy, ₹20,000
• • Phone2 → iPhone 15, ₹80,000
Advantages of Classes & Objects
• • Code reusability
• • Easy to maintain and understand
• • Models real-world problems
Key Points
• • Class = Design/blueprint
• • Object = Instance/product
• • Foundation of Java OOP
Conclusion
• • Classes and Objects are the basic building
blocks of Java
• • They make programs modular, reusable, and
easier to understand
• Thank You!