Class : Whatever we can see in this world all the things are a object. And all the objects are categorized in a special group. That group is termed as a class. All the objects are direct interacted with its class that mean almost all the properties of the object should be matched with it's own class. Object is the feature of a class which is used for the working on the particular properties of the class or its group. We can understand about the class and object like this : we are all the body are different - different objects of the human being class. That means all the properties of a proper person relates to the human being. Class has many other features like creation and implementation of the object, Inheritance etc.
In this Program you will see how to use the class, object and it's methods. This program uses the several values of several defined variables for getting the Area and Perimeter of the Square and Rectangle by calling the different functions from the different classes through the several objects created for the several class. In this program there are two classes has been used except the main class in which the main function is declared. First class is square which is using for getting the Area and Perimeter of the square and another class is rectangle which is using for getting the Area and Perimeter of the Rectangle. All the functions in the square and rectangle class are calling with different - different arguments two times for getting the Area and Perimeter of square and rectangle for two different sides. This program gives us the Area and Perimeter for the different sided Square and Rectangle separately. Full running code is given with the example :
Here is the code of the program :
Descriptions of the program:
Object : Objects are the basic run time entity or in other words object is a instance of a class . An object is a software bundle of variables and related methods of the special class. In the above example the sq is the object of square class and rect is the object of the rectangle class. In real-world objects share two characteristics: They have all state and behavior. For example, The squares have state such as : sides and behaviors such as its areas and perimeters. Rectangles have state such as: length, breadth and behavior such as its areas and perimeters. A object implements its behavior with methods of it's classes. A method is a function (subroutine) associated with an object.
Syntax for the Object :
class_name object_name = new class_name();
Output of the program :
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.