Communiquez avec les autres et partagez vos connaissances professionnelles

Inscrivez-vous ou connectez-vous pour rejoindre votre communauté professionnelle.

Suivre

What is the relationship between Class and Object ?

Class and object are two common terms in OOP, but what the different.

user-image
Question ajoutée par هاشم المشارقة , Key Account Manager , Advanced United Systems Ltd. ( A member of Taj Holding Group)
Date de publication: 2014/09/02
Tomasz Modrzejewski
par Tomasz Modrzejewski , Programmer , Company Skraw-Mech

To answer the question, let us ask the other: "What we call an object in the real world?" It turns out everything can be and is an object! Trees, animals, cities, cars, people ... Even activities can be reduced to the form of objects! In programming, an object can be any creature, about what we think. Creating "the world of the" you can create an object whose use will be more "tangible" a number of parameters, scattered in different variables. It differs from the structured programming object-oriented programming. Before you create an object, you need to determine what this object is? What it represents? What model is it? Depending on whether you want to create a virtual car, or plane, you must specify two things: »What properties - characteristics will have this property (eg. Length) »What will be the method of operation. (for example. accelerator as a function of acceleration) Therefore, before creating any object to be presented to the compiler its design (pattern), that determine its class. The class is therefore the object of programming determines what properties and methods will have objects that will be created on its basis. However, the project itself will not make again, that we get the objects. You still need to create an object, which simply means a declaration of an object based on a certain class.

object is inctance of class.instance means memory alloction at runtime of class.

class is define the structure state and behavoiur.state menas inctance data member of class and behavour means inctance method

Suraj  Umesh
par Suraj Umesh , ASSISTANT DRILLER TRAINEE , National Drilling Company Offshore Rig

instances created in class are called as objects

Ehtesham Ahmad Siddiquie
par Ehtesham Ahmad Siddiquie , Assistant system engineer , Tata Consultancy Services

A class in Java is a blueprint (template). It is a definition which contains the behaviour(method) and the state(attributes). This definition is not physical, which means that it does not occcupy any memory. An object is the instantiation of a class, which means that the definition of class is implemented physically by an object. Now to make the discussion simpler, A class is like an architectural drawing of a house. in the drawing it is defined what is the structure of the house, how many rooms it will have, etc. This is only a design but has no physical existence. When the house is actually constructed then the design comes into physical reality. This house is strictly defined by the drawing. Object is like the house which is defined by the class and has physical existence in memory.

anees anjum
par anees anjum , Intern , Pakistan Ordinance Factories

A class is a blueprint of distinct user defined data type while an object is a variable of that user defined data type

More Questions Like This

Avez-vous besoin d'aide pour créer un CV ayant les mots-clés recherchés par les employeurs?