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 datatype | It 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 |
| Template | Variable(Data members) |
| Blueprint | Methods(Member function) |
How class should creating…..
- Meaningful name
- Should not be a verb. (e.g – eat,sleep)
- Should start with capital letter.
- No special charecter allowed except underscore( _ )
- Should not start with numbers
- No space is allowed
- Should follow camel case. (e.g) ActivaBikeFromHonda