Sail E0 Webinar

MCQs

Total Questions : 76 | Page 5 of 8 pages
Question 41.

Which of the following statements are true in c++?


  1.    Classes can not have data as public members.
  2.    Structures can not have functions as members
  3.    Class members are public by default.
  4.    None of these.
 Discuss Question
Answer: Option B. -> Structures can not have functions as members



Question 42.

Which of the following is the valid class declaration header for the derived class d with base classes b1 and b2?


  1.    class d : public b1, public b2
  2.    class d : class b1, class b2
  3.    class d : public b1, b2
  4.    class d : b1, b2
 Discuss Question
Answer: Option A. -> class d : public b1, public b2


Question 43.

If we create a file by ‘ifstream’, then the default mode of the file is _________


  1.    ios :: out
  2.    ios :: in
  3.    ios :: app
  4.    ios :: binary
 Discuss Question
Answer: Option B. -> ios :: in



Question 44.

An exception is caused by


  1.    a runtime error.
  2.    a syntax error.
  3.    a problem in the operating system.
  4.    a hardware problem.
 Discuss Question
Answer: Option A. -> a runtime error.


Question 45.

Pure virtual functions


  1.    have to be redefined in the inherited class.
  2.    cannot have public access specification.
  3.    are mandatory for a virtual class.
  4.    None of the above.
 Discuss Question
Answer: Option A. -> have to be redefined in the inherited class.


Question 46.

What will be the result of the expression 13 & 25?


  1.    38
  2.    25
  3.    9
  4.    12
 Discuss Question
Answer: Option C. -> 9



Question 47.

Declaration of a pointer reserves memory space


  1.    for the object.
  2.    for the pointer
  3.    both for the object and the pointer.
  4.    None of these
 Discuss Question
Answer: Option B. -> for the pointer



Question 48.
Function templates can accept
  1.    any type of parameters
  2.    only one parameter
  3.    only parameters of the basic type
  4.    only parameters of the derived type
 Discuss Question
Answer: Option C. -> only parameters of the basic type



Question 49.

Consider the following class definitions:
class a
{
};


class b: protected a
{
};


What happens when we try to compile this class?


  1.    Will not compile because class body of a is not defined.
  2.    Will not compile because class body of b is not defined.
  3.    Will not compile because class a is not public inherited.
  4.    Will compile successfully.
 Discuss Question
Answer: Option D. -> Will compile successfully.



Question 50.

A class defined within another class is:


  1.    Nested class
  2.    Inheritance
  3.    Containership
  4.    Encapsulation
 Discuss Question
Answer: Option A. -> Nested class


Latest Videos

Latest Test Papers