Function Overloading in C++
15 questions · 12 min · Medium
Test your knowledge of C++ objects and classes, including class definitions, object creation, access specifiers, constructors, destructors, member functions, encapsulation, static members, and the fundamentals of object-oriented programming.
No sign-up needed · Last updated:
Score: 0 00:00
Create a free account to keep your scores and track your progress. It is optional.
15 questions · 12 min · Medium
15 questions · 12 min · Medium
15 questions · 12 min · Medium
15 questions · 12 min · Medium
20 questions · 15 min · Medium
15 questions · 12 min · Medium
B. A user-defined type that groups data members and member functions
A class is a user-defined type that combines data and functions into a single unit.
C. class
The class keyword introduces a class definition in C++.
B. Car object;
The declaration Car object; creates an object named object of the class type Car.
C. private
Members of a class are private by default, so they cannot normally be accessed directly from outside the class.
B. public
Public members can be accessed from outside the class through an object or other valid access path.
A. A special member function used to initialize objects
A constructor is called when an object is initialized and can establish its initial state.
B. Its name must match the class name
A constructor has the same name as its class and does not declare a return type.
C. To perform cleanup when an object's lifetime ends
A destructor can release resources owned by an object when its lifetime ends.
C. ~Student()
A destructor uses the class name preceded by a tilde, such as ~Student().
B. obj.function()
The dot operator accesses a member through an object. The arrow operator is typically used with a pointer to an object.
A. Combining data and related functions while controlling access to them
Encapsulation groups related data and behavior and uses access controls to protect an object's internal state.
C. A member associated with the class rather than a separate copy for each object
A static data member belongs to the class and is shared by its objects rather than having a separate instance for each object.
C. ::
The scope resolution operator :: can access a static member through the class name, as in Counter::count.
B. A separate parameter object is initialized from the argument
Passing an object by value initializes a separate parameter object, usually through a copy or move operation. The original object is not automatically destroyed.
D. Each object normally has its own non-static data members
Each object has its own instance state through non-static data members, while static data members are shared at the class level.