C++ Concepts(C++ Programming ) Questions and Answers
Question 1.
In access control in a protected derivation, visibility modes will change as follows:
private, public and protected become protected
only public becomes protected.
public and protected become protected.
only private becomes protected.
Explanation:-
Answer: Option C. -> public and protected become protected.
Question 2.
How many constructors can a class have?
0
1
2
Any Number
Explanation:-
Answer: Option D. -> Any Number
Question 3.
A template class
is designed to be stored in different containers
works with different data types
generates objects which must be identical
generates classes with different numbers of member functions.
Explanation:-
Answer: Option B. -> works with different data types
Question 4.
What is the output of given code fragment?
int f=1, i=2; while(++i<5) f*=i; cout<<f;
12
24
6
3
Explanation:-
Answer: Option A. -> 12
Question 5.
A pure virtual function is a virtual function that
has no body
returns nothing
is used in base class
both A and C
Explanation:-
Answer: Option D. -> both A and C
Question 6.
Name the header file to be included for the use of built in function isalnum()
string.h
process.h
ctype.h
dos.h
Explanation:-
Answer: Option C. -> ctype.h
Question 7.
A static function
should be called when an object is destroyed
is closely connected with and individual object of a class.
can be called using the class name and function name.
is used when a dummy object must be created.
Explanation:-
Answer: Option C. -> can be called using the class name and function name.
Question 8.
Which of the following ways are legal to access a class data member using this pointer?
this.x
*this.x
*(this.x)
(*this).x
Explanation:-
Answer: Option D. -> (*this).x
Question 9.
Which of the following is not the characteristic of constructor.
They should be declared in the public section.
They do not have return type.
They can not be inherited.
They can be virtual.
Explanation:-
Answer: Option D. -> They can be virtual.
Question 10.
If there is a pointer p to object of a base class and it contains the address of an object of a derived class and both classes contain a virtual member function abc(), then the statement
p->abc();
will cause the version of abc() in the __________class to be executed.