Elementry Concepts of Classes and Objects
Elementry Concepts of Classes and Objects
AS U ALL KNOW THERE THAT THERE ARE 4 PRINCIPLES OF OBJECT ORIENTED PROGRAMMING SYSTEM ( OOPS ) ,
DATA ABSTRACTION, POLYMORPHISM , ENCASULATION , INHERITENCE . IN OOPS BOTH CLASSES AND OBJECTS CO-
RELATE WITH EACH OTHER
What is a class?
A class can be classified as a category and its objects share the same characteristics and qualities, to understand this
we can take the example of a car.
Objects ->maruti,Hyundai,Toyota.
Objects ->santro,verna,venue.
DEFINITION OF CLASS :- A class is a template or blueprint for multiple objects with similar features and
may be regarded as specification for creating similar objects.
What is an object?
AN OBJECT IS THE FUNDAMENTAL UNIT OF OOPS AND REPRESENTS REAL LIFE ENTITIES , IN OOPS THE ATTEMPTS ARE MADE TO
BREAK A TASK INTO SOME COMPONENTS , CALLED OBJECTS
Object is instance of a class :- the data members that are declared within a class are also known as instance
variables. When an object of class is created ,it variables described within the class.
IN ALL WE CAN SAY THAT A CLASS IS DESCRIBED WITH SOME CHARACTERISTICS ( DATA MEMBERS or MEMBER
VARIABLES) AND BEHAVIOURS(MEMBER FUNCTIONS).
SOFTWARE OBJECTS
MESSAGE PASSING : - OBJECTS CAN INTERACT WITH EACH OTHER . AN OBJECT CAN PASS INFORMATION TO OTHER
OBJECT AND RECEIVE AS WELL . THEY INTERACT THROUGH BEHAVIOUR OR FUNCTIONS , WHICH ARE KNOWN AS
MESSAGE PASSING. SO WE CAN SAY OBJECTS INTERACT WITH EACH OTHER THROUGH MESSAGES
KINDS OF OBJECTS :-
1. TANGIBLE OBJECTS – THESE U CAN TOUCH AND FEEL FOR EX. PEN PAPER ETC.
2. CONCEPTUAL OBJECTS – THESE ARE INTANGIBLE AND EXIST ONLY AS A CONCEPT FOR EX. BANK ACCOUNT ,
AN EMAIL ETC.
3. ROLES – ROLES PLAYED BY PEOPLE FOR EX. TEACHER , CLERK ETC.
4. EVENTS – AN EVENT IS WHEN SOMETHING IS HAPPENING SOMEWHERE. FOR EX .SALES , PURCHASES ,
AUDITING OF ACCOUNTS , REPAIR OF A CAR ETC.
Objects that share same attributes and behaviours are grouped together in a class.due to this reason , class is also
known as object factory the produces multiple objects at a same time.
As we know java has some pre-defined data types e.g. int,char etc. these data types are used to declare variables
and it possesses its built-in characteristics. similarly when a class is created by the programmer it possesses all the
characteristics of the attributes( data members , member variables , member functions , etc ) it contains .
CLASS OBJECT
It is not real and it is representation of abstraction It is real and unique . It possesses the characteristics of
all the attributes that it contains.
It is an object producer hence called blue print for a set It is created by the help of “new” keyword.
of objects
It is known as “object factory”. It is also known as “ instance of the class”.
An object stores or possesses the member variables as states and behaviour as member functions.The member
functions operate upon the member variables. Only member methods defined inside a class can have access to the
member variables or data members and can change its state , hence we can say that state and behaviour are
encapsulated within an object.
What is an entity?
ACCESS SPECIFIERS : these are the keywords which are used to define the scope of the usage of data
members and functions in a program of java. It defines the level of the usage of data members.There are 3
kinds of access specifiers .
a. Public
b. Private
c. Protected
Public : class members( variables and methods ) can be used anywhere , even outside the class, but within
a program.
SYNTAX.
public int a=10;
public void compute()
public class abc