Object Creation.

How object is creation?

Car engine = new Car( );

Mobile vivo = new Mobile( );

Car—> class name. vivo —> object name.

new —-> new keyword is allocation memory for object creation

object —> object is memory reference of the variable

variable —>variable is represents data type

object—>object is represents class

what is state?

state is a attribute. it also called charecter.

Different between variable and object ?

VARIABLE OBJECTS
It represents primitive datatypeIt represents class
It contains only values(state).Object contains values(state) and behaviour
‘new’ keyword is not needed‘new’ keyword is needed for allocating memory
Size is fixed (e.g- int name=5;)Size is not fixed dynamic one

If i choose mobile is an object. then,

state = mobile size, mobile price, camera pixel, battery color, mobile color.

behaviour = chatting, call, browsing.

CLASS OBJECT
TemplateVariable(Data members)
BlueprintMethods(Member function)

How class should creating…..

  1. Meaningful name
  2. Should not be a verb. (e.g – eat,sleep)
  3. Should start with capital letter.
  4. No special charecter allowed except underscore( _ )
  5. Should not start with numbers
  6. No space is allowed
  7. Should follow camel case. (e.g) ActivaBikeFromHonda

Leave a comment