0% found this document useful (0 votes)
16 views3 pages

Elementry Concepts of Classes and Objects

Uploaded by

sparshgoyal6386
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)
16 views3 pages

Elementry Concepts of Classes and Objects

Uploaded by

sparshgoyal6386
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/ 3

ACES

ACADEMY OF COMPUTER AND ENGLISH STUDIES

ELEMENTRY CONCEPTS OF OBJECTS AND CLASSES

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.

Class -> CAR

Objects ->maruti,Hyundai,Toyota.

Common characteristics -> all have 4 doors.

All have 2 lights.

All have 4 wheels.

Class -> Hyundai

Objects ->santro,verna,venue.

Common characteristics -> all have 4 doors

All have 4 wheels

All have a steering wheel.

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).

THERE ARE 2 TYPES OF OBJECTS :

1. REAL WORLD OBJECTS


2. SOFTWARE OBJECTS

REAL WORLD OBJECTS ARE :


1. VISIBLE TO US
2. IT HAS DEFINITE SHAPE AND SIZE
3. IT CAN BE BROUGHT INTO THOUGHTS AND FIGURES

SOFTWARE OBJECTS

1. EXISTES ONLY IN SOFTWARE WORLD


2. DOES NOT HAVE A SHAPE
3. USED TO ACCESS FUNCTIONS OF A CLASS

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.

WHY CLASS IS AN OBJECT FACTORY ?

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.

CLASS AS IS A USER DEFINED DATA TYPE :-

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 .

So a class can be referred as USER DEFINED.


DIFFERENCE BETWEEN CLASS AND OBJECT

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”.

How objects encapsulate state and behaviour?

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?

An entity is something which exists on itself , either in concrete or conceptual form.

Internal contents of a class

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

private : data members can be accessed within a particular class itself


SYNTAX
private int a=10;
private void compute()
private class abc
protected : data members can be accessed within scope of a class but they can be used by all classes under
inheritance.
SYNTAX
protected int x=10;
protected void compute()
protected class abc

You might also like