0% found this document useful (0 votes)
27 views

OOPS in Java

Uploaded by

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

OOPS in Java

Uploaded by

bunnybro2953
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

OOPS IN JAVA

G.Sidhartha 22D41A1223
K.Varsha Sri 22D41A1236
M.Sai venkat 22D41A1241
R.Ajay 22D41A1252
In Java, "Oops" typically refers to Object-Oriented
Programming (OOP) concepts. Java is a strongly
object-oriented language, and it implements key OOP
principles such as:
Classes and Objects: Classes in Java are blueprints
for objects. They define attributes (fields) and
behaviors (methods) that objects of that class can
exhibit.
Inheritance: Inheritance is a mechanism where a new class (subclass) can inherit properties
and behaviors from an existing class (superclass). This promotes code reusability and allows
for hierarchical relationships between classes.
Polymorphism: Polymorphism means the ability to take on many forms. In Java, polymorphism
is achieved through method overloading (compile-time polymorphism) and method overriding
(run-time polymorphism). It allows methods to behave differently based on the object that is
invoking them.
Encapsulation: Encapsulation refers to bundling the data (attributes) and methods that
operate on the data into a single unit (class). Access to the data is typically restricted to
methods of the class, which helps in hiding the internal state and protecting it from external
interference.
Abstraction: Abstraction focuses on the essential features of an object while hiding its
complex implementation details. In Java, abstraction is achieved through abstract classes
and interfaces. Abstract classes cannot be instantiated and may contain abstract methods
that subclasses must implement. Interfaces define a contract that implementing classes
must adhere to.
Inheritance:
Inheritance is a fundamental concept in Java and Object-
Oriented Programming (OOP) in general. It allows one class to
inherit properties and behaviors from another class,
promoting code reuse and establishing hierarchical
relationships between classes.
•Superclass (Parent Class): Also known as a base class or parent
class, it is the class being extended or inherited from.
•Subclass (Child Class): Also known as a derived class, it is the
class that inherits from another class (superclass).
Example syntax: class Subclass extends Superclass { .. }
Abstraction:
Abstraction in Java is a powerful concept used to simplify
complexity and manage software design effectively.
Abstract Class: An abstract class in Java is declared with the
abstract keyword. It can contain abstract methods (methods
without a body) that must be implemented by its subclasses.
Abstract classes cannot be instantiated directly; they are
meant to be extended by subclasses that provide concrete
implementations of the abstract methods.
Encapsulation:
Encapsulation in Java is a fundamental principle of object-
oriented programming that involves bundling the data
(variables) and methods (functions) that operate on the data
into a single unit, called a class. It helps in hiding the internal
state of an object from outside interference and manipulation.

Getters and Setters: These are public methods that provide


access to the private variables of the class. Getters return
the value of the variable, and setters modify the value of
the variable.
Polymorphism:
Polymorphism in Java is a core concept of object-oriented
programming (OOP) that allows objects to be treated as
instances of their parent class or as instances of their own
class types. It enables methods to be called on objects of
different classes through a common interface, providing
flexibility and extensibility to your code. There are two types of
polymorphism in Java:
Compile-time (static) polymorphism
Runtime (dynamic) polymorphism
Advantages: Disadvantages:
• Modularity • Steeper learning curve
• Reusability • Larger memory footprint
• Slower execution speed
• Extensibility
• Difficulty in designing
• Encapsulation • Overhead of maintaining
• Abstraction state
• Polymorphism • Limited efficiency in
• Maintainability certain types of
computations
Conclusion:
In conclusion, Object-Oriented Programming (OOP)
brings significant benefits to software development,
such as modularity, reusability, and maintainability.
However, it also comes with certain drawbacks,
including a steeper learning curve and potential
overhead in terms of memory and performance.
Despite its limitations, OOP remains a widely adopted
paradigm due to its ability to model real-world entities
effectively and promote scalable, organized codebases.
Thank You

You might also like