CPP Programming Set 1
CPP Programming Set 1
CPP Programming Set 1
o m
B. When an object of the class is passed (to a function) by value as an argument.
. c
C. When an object is constructed based on another object of the same class
D. All of the above te
Answer: D a
q M
c
3. Constructors have _____ return type.
A. void
B. char
M
C. int
D. no
Answer: D
7. #include<iostream>
using namespace std;
class Point {
public:
Point() { cout << "Constructor called"; }
};
int main()
{
Point t1, *t2;
return 0;
}
A. Compiler Error
B. Constructor called Constructor called
16. A member function can always access the data in __________, (in C++).
A. the class of which it is member
B. the object of which it is a member
C. the public part of its class
D. the private part of its class
Answer: A
17. Which of the following is not correct for virtual function in C++?
A. Must be declared in public section of class.
B. Virtual function can be static.
C. Virtual function should be accessed using pointers.
D. Virtual function is defined in base class.
Answer: B
20. Which of the following, in C++, is inherited in a derived class from base class?
A. Constructor
B. Destructor
C. Data members
D. Virtual methods
Answer: C
23. When a method in a subclass has the same name and type signatures as a
method in the superclass, then the method in the subclass _____ the method in the
superclass.
A. Overloads
B. Friendships
C. Inherits
24. It is possible to define a class within a class termed as nested class. There are
_____ types of nested classes.
A. 2
B. 3
C. 4
D. 5
Answer: A
25. When one object reference variable is assigned to another object reference
variable then
A. a copy of the object is created.
B. a copy of the reference is created.
C. a copy of the reference is not created.
D. it is illegal to assign one object reference variable to another object reference variable.
Answer: B