Sail E0 Webinar

C++ Programming

C++ CONCEPTS MCQs

Total Questions : 76 | Page 1 of 8 pages
Question 1.

In access control in a protected derivation, visibility modes will change as follows:


  1.    private, public and protected become protected
  2.    only public becomes protected.
  3.    public and protected become protected.
  4.    only private becomes protected.
 Discuss Question
Answer: Option C. -> public and protected become protected.



Question 2.

How many constructors can a class have?


  1.    0
  2.    1
  3.    2
  4.    Any Number
 Discuss Question
Answer: Option D. -> Any Number



Question 3.

A template class


  1.    is designed to be stored in different containers
  2.    works with different data types
  3.    generates objects which must be identical
  4.    generates classes with different numbers of member functions.
 Discuss Question
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;
  1.    12
  2.    24
  3.    6
  4.    3
 Discuss Question
Answer: Option A. -> 12


Question 5.

A pure virtual function is a virtual function that


  1.    has no body
  2.    returns nothing
  3.    is used in base class
  4.    both A and C
 Discuss Question
Answer: Option D. -> both A and C



Question 6.

Name the header file to be included for the use of built in function isalnum()


  1.    string.h
  2.    process.h
  3.    ctype.h
  4.    dos.h
 Discuss Question
Answer: Option C. -> ctype.h



Question 7.

A static function


  1.    should be called when an object is destroyed
  2.    is closely connected with and individual object of a class.
  3.    can be called using the class name and function name.
  4.    is used when a dummy object must be created.
 Discuss Question
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?


  1.    this.x
  2.    *this.x
  3.    *(this.x)
  4.    (*this).x
 Discuss Question
Answer: Option D. -> (*this).x



Question 9.

Which of the following is not the characteristic of constructor.


  1.    They should be declared in the public section.
  2.    They do not have return type.
  3.    They can not be inherited.
  4.    They can be virtual.
 Discuss Question
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.


  1.    Base Class
  2.    Derived Class
  3.    Produces compile time error
  4.    produces runtime error
 Discuss Question
Answer: Option B. -> Derived Class


Latest Videos

Latest Test Papers