0% found this document useful (0 votes)
5 views8 pages

Java OOP Concepts Explained with Examples

Uploaded by

duddulapranathi
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views8 pages

Java OOP Concepts Explained with Examples

Uploaded by

duddulapranathi
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd

Java OOP Concepts

Definition, Code Examples, and Real-


Time Examples
What is OOPS?
• • OOPS stands for Object-Oriented
Programming System
• • Uses objects and classes to organize code
• • Helps in reusability, security, and easier
maintenance
Class
• • Definition: A class is a blueprint/template for
creating objects
• • Code:
• class Car {
• String color;
• void drive() { [Link]("Car is
driving"); }
• }
• • Real-Time Example: Car blueprint
Object
• • Definition: An object is an instance of a class
• • Code: Car c1 = new Car();
• • Real-Time Example: Actual car built from
blueprint
Encapsulation
• • Definition: Wrapping data and methods
together and hiding data using private access
• • Code:
• class Student {
• private int age;
• public void setAge(int a){ age = a; }
• public int getAge(){ return age; }
• }
• • Real-Time Example: ATM hides data
Inheritance
• • Definition: One class acquires properties of
another
• • Code:
• class Animal { void eat(){} }
• class Dog extends Animal { void bark(){} }
• • Real-Time Example: Child inherits traits from
parents
Polymorphism
• • Definition: One name, many forms
• • Method Overloading:
• int add(int a, int b); int add(int a, int b, int c);
• • Method Overriding:
• Dog overrides Animal's sound()
• • Real-Time Example: Person speaks in many
languages
Abstraction
• • Definition: Showing only essential
information, hiding internal details
• • Code:
• abstract class Vehicle { abstract void start(); }
• class Bike extends Vehicle { void start(){} }
• • Real-Time Example: Driving car without
knowing internal engine working

You might also like