A class is like a blueprint which - Expert Answers

A class is like a blueprint which - Expert Answers

Question 1

A class is like a blueprint which you use to create objects. An object is an instance of a class. It's a thing that you made out of a specific class. Basically, object and instance mean the same, but the word instance could indicates the its relationship to class.

Example: Cup cakes. Cups could be seen as classes, and the cakes can be seen as objects. The same cup can make many cakes with the same shape, and the cakes in the same shape must be made out of the same cup.

Question 2

Function overloading is a feature in many programming language, which means that you can create multiple functions with the same name but the parameters within the functions should be different.

Two prototypes: int add(int x, int y) and double add(double x, double y) are two functions with the same name add but they have different parameters of different data type, so they are valid in some programming languages.

Question 3 

When making an attribute of a class static, the static attribute is created in the memory when the class is initiated.Static attributes can be access by all objects/instances created out of the class, since static attributes are only allocated once in the memory, and it will remain in the memory until the last instance of the class is deallocated. When we need an attribute to be accessed and modified by all the objects universally, making it static will be a good choice.
Powered by