Sunday 23 March 2014

Class and Objects

Class and Objects

Why do we need  Objects and Classes ?

For real time object we need real time data which can be created through Objects and Classes.

CLASS :

 - Classes are used to create user-defined /real time data types.

 -Syntaxically Class is a collection of member data and member function.

 NOTE : member data is also called attributes and member function is also called methods.

- Class implements Data Abstraction and Data Encapsulation.

 -Syntax of  Class :-
<Acess Spcifier> Class< Class Name>{

//member data
//member function
}

OBJECTS :


- Instances of class.

-Stores data and invokes methods.

-Syntax of  Object :-

<Class Name> <Object Name>=new <Class Name>();



Example : For Objects and Classes


 


 PROGRAM:   

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

OUTPUT:

 

 

 

 


No comments:

Post a Comment

Chapter : 1 - First code in Node JS Previously I have written a blog about Getting Started with Node JS and its installation. Now lets s...