We are created the object of the Rectangle3 class by using new keyword and printing the objects value. And we have created two methods getdata( ) and putdata( ) which gets the data and displays the data respectively. In this program, we have created a Rectangle3 class that have two data members length and width. Object_name = new class_name( ) // Instantiating object of classĬlass_name object_name = new class_name( ) // Creating object The syntax for creating an object of class is shown below:Ĭlass_name object_name // Create object reference Objects of specific class are created using new operator which returns reference of that object. Creating an object is referred to an object. A method has a return type such as void, int, etc. Where, type is the data type of a variable which it may hold. A class is declared by use of the class keyword. It is a template for an object, and an object is an instance of a class. A class is a collection of objects that has common properties.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |