OOPs (Object Oriented Programming System)
Object-oriented programming is a way of solving a complex problem by breaking them into a small sub-
problem. An object is a real-world entity. It is easier to develop a program by using an object. In OOPs, we
create programs using class and object in a structured manner.
Class: A class is a template or blueprint or prototype that defines data members and methods of an object.
An object is the instance of the class. We can define a class by using the class keyword.
Object: An object is a real-world entity that can be identified distinctly. For example, a desk, a circle can
be considered as objects. An object has a unique behavior, identity, and state. Data fields with their current
values represent the state of an object (also known as its properties or attributes).
Abstraction: An abstraction is a method of hiding irrelevant information from the user.
For example, the driver only knows how to drive a car; there is no need to know how does the car run. We
can make a class abstract by using the keyword abstract. In Java, we use abstract class and interface to achieve
abstraction.
Encapsulation: An encapsulation is the process of binding data and functions into a single unit. A class is
an example of encapsulation. In Java, Java bean is a fully encapsulated class.
Inheritance: Inheritance is the mechanism in which one class acquire all the features of another class. We
can achieve inheritance by using the extends keyword. It facilitates the reusability of the code.
Polymorphism: The polymorphism is the ability to appear in many forms. In other words, single action in
different ways. For example, a boy in the classroom behaves like a student, in house behaves like a son.
There are two types of polymorphism: run time polymorphism and compile-time polymorphism.
Dynamic binding: Binding refers to the linking of a procedure call to the code to be executed in response
to the call. Dynamic binding also known as latebinding means that the code associated with a given
procedure call is not known until the time of the call at run-time.
Message communication: An object – oriented program consists of a set of objects that communicate with
each other. The process of programming in an object-oriented language therefore involves the following
basic steps:
1. Creating classes that define objects and their behavior.
2. Creating objects from class definitions and
3. Establishing communication among object
, What is a class in Java
A class is a group of objects which have common properties. It is a template or blueprint from which objects are
created. It is a logical entity. It can't be physical.
A class in Java can contain:
o Fields
o Methods
o Constructors
o Blocks
o Nested class and interface
Syntax to declare a class:
class <class_name>
{
field; //data member
method; //member function
}
Rules for defining a class:
1. The name start with a capital letter
2. They can be only one public class per program
3. A program can have any number of non-public classes
INSTANCE VARIABLES AND MEMBER METHODS
Instance variables and member methods are fundamental components of a class.
1. Instance Variables:
Instance variables are variables that belong to an object (or instance) of a class.
They are declared inside a class but outside any methods or constructors.
Each object of the class has its own copy of the instance variables.
Instance variables store the state or attributes of an object
2. Member Methods:
Member methods are functions (or methods) that are defined inside a class.
They define the behavior of the objects (instances) of that class.
Member methods can access and modify instance variables and provide functionality to objects.
They can either operate on individual instances or be static methods that operate without creating an instance
Object-oriented programming is a way of solving a complex problem by breaking them into a small sub-
problem. An object is a real-world entity. It is easier to develop a program by using an object. In OOPs, we
create programs using class and object in a structured manner.
Class: A class is a template or blueprint or prototype that defines data members and methods of an object.
An object is the instance of the class. We can define a class by using the class keyword.
Object: An object is a real-world entity that can be identified distinctly. For example, a desk, a circle can
be considered as objects. An object has a unique behavior, identity, and state. Data fields with their current
values represent the state of an object (also known as its properties or attributes).
Abstraction: An abstraction is a method of hiding irrelevant information from the user.
For example, the driver only knows how to drive a car; there is no need to know how does the car run. We
can make a class abstract by using the keyword abstract. In Java, we use abstract class and interface to achieve
abstraction.
Encapsulation: An encapsulation is the process of binding data and functions into a single unit. A class is
an example of encapsulation. In Java, Java bean is a fully encapsulated class.
Inheritance: Inheritance is the mechanism in which one class acquire all the features of another class. We
can achieve inheritance by using the extends keyword. It facilitates the reusability of the code.
Polymorphism: The polymorphism is the ability to appear in many forms. In other words, single action in
different ways. For example, a boy in the classroom behaves like a student, in house behaves like a son.
There are two types of polymorphism: run time polymorphism and compile-time polymorphism.
Dynamic binding: Binding refers to the linking of a procedure call to the code to be executed in response
to the call. Dynamic binding also known as latebinding means that the code associated with a given
procedure call is not known until the time of the call at run-time.
Message communication: An object – oriented program consists of a set of objects that communicate with
each other. The process of programming in an object-oriented language therefore involves the following
basic steps:
1. Creating classes that define objects and their behavior.
2. Creating objects from class definitions and
3. Establishing communication among object
, What is a class in Java
A class is a group of objects which have common properties. It is a template or blueprint from which objects are
created. It is a logical entity. It can't be physical.
A class in Java can contain:
o Fields
o Methods
o Constructors
o Blocks
o Nested class and interface
Syntax to declare a class:
class <class_name>
{
field; //data member
method; //member function
}
Rules for defining a class:
1. The name start with a capital letter
2. They can be only one public class per program
3. A program can have any number of non-public classes
INSTANCE VARIABLES AND MEMBER METHODS
Instance variables and member methods are fundamental components of a class.
1. Instance Variables:
Instance variables are variables that belong to an object (or instance) of a class.
They are declared inside a class but outside any methods or constructors.
Each object of the class has its own copy of the instance variables.
Instance variables store the state or attributes of an object
2. Member Methods:
Member methods are functions (or methods) that are defined inside a class.
They define the behavior of the objects (instances) of that class.
Member methods can access and modify instance variables and provide functionality to objects.
They can either operate on individual instances or be static methods that operate without creating an instance