Java एक Object-Oriented Programming (OOP) भाषा है। OOPs का मतलब है Object-Oriented Programming, यानी प्रोग्रामिंग का तरीका जो Objects और Classes के आधार पर काम करता है।
Java OOPs के मुख्य लाभों में कोड का पुनः उपयोग (Reusability), सुरक्षा (Security), आसान मेंटेनेंस (Easy Maintenance) शामिल हैं।
1. Java OOPs क्या है?
Java में OOPs एक प्रोग्रामिंग तकनीक है जिसमें हम Objects और Classes का उपयोग करके प्रोग्राम बनाते हैं।
Class → Blueprint (ढांचा)
Object → Class का वास्तविक instance
उदाहरण:
Class → Car
Object → Red Ferrari
2. Java OOPs के मुख्य Concepts
2.1 Class (क्लास)
Class एक template होती है जिसमें properties (attributes) और methods (functions) होते हैं।
class Car {
String color;
int speed;
void drive() {
System.out.println(“Car is driving”);
}
}
2.2 Object (ऑब्जेक्ट)
Object class का instance होता है।
Car myCar = new Car();
myCar.color = “Red”;
myCar.drive();
2.3 Encapsulation (इनकैप्सुलेशन)
Encapsulation का मतलब है डेटा और methods को class में secure करना।
Private variables
Getter और Setter methods
class Person {
private String name;
public void setName(String name) {
this.name = name;
}
public String getName() {
return name;
}
}
2.4 Inheritance (इनहेरिटेंस)
Inheritance से एक class दूसरी class की properties और methods inherit कर सकती है।
class Animal {
void eat() {
System.out.println(“Animal is eating”);
}
}
class Dog extends Animal {
void bark() {
System.out.println(“Dog is barking”);
}
}
2.5 Polymorphism (पॉलीमॉर्फिज़्म)
Polymorphism का मतलब है एक चीज़ के कई रूप।
Method Overloading → Compile-time
Method Overriding → Run-time
class MathOperation {
int add(int a, int b) { return a + b; }
double add(double a, double b) { return a + b; }
}
2.6 Abstraction (एब्स्ट्रैक्शन)
Abstraction का मतलब है केवल जरूरी चीजें दिखाना, बाकी छुपाना।
Abstract Class या Interface से implement होता है
abstract class Shape {
abstract void draw();
}
class Circle extends Shape {
void draw() {
System.out.println(“Drawing Circle”);
}
}
3. Java OOPs के Advantages (फायदे)
Code Reusability – एक बार code लिखने के बाद उसे multiple places पर reuse किया जा सकता है।
Data Security – Encapsulation के कारण private data secure रहता है।
Easy Maintenance – Objects और classes की वजह से code maintain करना आसान।
Flexibility – Polymorphism और Inheritance से flexible design।
Real-World Modelling – Objects से real-world entities को represent करना आसान।
4. Java OOPs के Disadvantages (नुकसान)
Complexity – Beginners के लिए थोड़ा मुश्किल हो सकता है।
Memory Usage – Objects बनाने से memory ज्यादा use होती है।
Performance Overhead – Inheritance और polymorphism के कारण कभी-कभी performance slow हो सकती है।
5. Java OOPs Types / Categories
Java OOPs मुख्य रूप से 6 प्रकार के होते हैं:
Class and Object – Blueprint और instance
Encapsulation – Data को secure करना
Inheritance – Code reusability
Polymorphism – Multiple forms of same entity
Abstraction – Complexity छुपाना
Association, Aggregation, Composition – Advanced relationships between classes
निष्कर्ष (Conclusion)
Java OOPs programming को structured, secure, और reusable बनाता है।
अगर आप Java developer बनना चाहते हैं तो OOPs concepts सीखना बहुत जरूरी है।

