Elementary Concept of Objects and
Objects: - Classes
Object is a fundamental unit of Object Oriented Programming.
They are referred to as entities. Objects are categorized in two
ways:
[Link] World Objects
[Link] Objects
An object is also called as an instance of a class.
Real World Objects
These objects are the ones that we experience in our day-to-
day life. Following are some of its features:
[Link] is visible to us.
[Link] have a definite shape and size.
[Link] can be brought in thoughts and figures.
Each real-world object contains characteristics and
Software Objects
It is an object that is created while writing a Java program.
It contains data members and methods.
For example :
A mobile phone (cell phone) can be defined as a real-world
entity.
Characteristics:
Model, display size, camera etc.
Behaviors : used to call , send messages, chat etc
The state or characteristics of the real-world objects are
considered to be data members in the software objects.
The behaviors in the real-world objects are considered to
be the methods in the software objects.
Define Object:
Object is an identifiable entity
with specific characteristics and
behavior. It is also called as an
instance of a class.
Define class:
A class is a blueprint or
template for its objects. It is a
collection of similar types of
How to create an object in java: Syntax:
<class name> <object name> = new <class
name> (); Example:
Student s1 = new Student ();
Car bmw = new Car();
Name the keyword that is used to create an
object in java?
new is the keyword that is used to create an
object in java. It allocates space in the
dynamic memory for creating an object.
DIFFERENCES BETWEEN A CLASS AND AN OBJECT:
CLASS OBJECT
It is a representation of an It is a real and
abstraction. unique entity.
It is an object It is created using
producer. “new” operator.
It is known as the
It is known as an object instance of a class.
factory.
Class is an object factory – Comment
A class is also referred to as an object factory.
Comment.
With one class, we can create several objects of similar type.
Thus, a class is also referred to as an object factory.
Class is a user defined data type.
Why is a class known as composite data type?
A class is known as a composite data type because classes are
made up of primitive data types. They are more complicated
than primitive data types. They contain both characteristics
and behavior.
Object is an instance of a class.
Why is an object called as an instance of a class? Explain.
When we create several objects from a class, each
object gets unique properties
of their own. And these objects actually exist in
the dynamic memory of the computer. Thus, an
object is called an instance of a class.