Classes(Engineering > Computer Science And Engineering > C++ Language ) Questions and Answers

Question 1. Which interface decides determines how your class will be used by other program?
  1.    public
  2.    private
  3.    protected
  4.    None of the mentioned
Explanation:-
Answer: Option A. -> public


If we invoked the interface as public means, We can access the program from other programs also.



Question 2. How many types of class are there in c++?
  1.    1
  2.    2
  3.    3
  4.    4
Explanation:-
Answer: Option C. -> 3


There are three types of classes. They are abstract base classes, concrete derived classes, standalone classes.



Question 3. Pick out the correct statement about override.
  1.    Overriding refers to a derived class function that has the same name and signature as a base class virtual function.
  2.    Overriding has different names
  3.    both a & b
  4.    None of the mentioned
Explanation:-
Answer: Option A. -> Overriding refers to a derived class function that has the same name and signature as a base class virtual function.


Overriding refers to a derived class function that has the same name
and signature as a base class virtual function.



Question 4. How many ways of reusing are there in class hierarchy?
  1.    1
  2.    2
  3.    3
  4.    4
Explanation:-
Answer: Option B. -> 2



Class hierarchies promote reuse in two ways. They are code sharing and interface sharing.



Question 5. What will happen when introduce the interface of classes in a run-time polymorphic hierarchy?
  1.    Separation of interface from implementation
  2.    Merging of interface from implementation
  3.    Separation of interface from debugging
  4.    None of the mentioned
Explanation:-
Answer: Option A. -> Separation of interface from implementation


Separation of interface from implementation



Question 6. Which classes are called as mixin?
  1.    Represent a secondary design
  2.    Classes express functionality which represent responsibilities.
  3.    Both a & b
  4.    None of the mentioned
Explanation:-
Answer: Option B. -> Classes express functionality which represent responsibilities.


A class that expresses functionality rather than its primary design role is called a mixin.



Question 7. What does the cerr represent?
  1.    Standard error stream
  2.    Standard logging stream
  3.    Input stream
  4.    Output stream
Explanation:-
Answer: Option A. -> Standard error stream


cerr is an object of class ostream that represents the standard error stream. It is associated with the cstdio stream stderr.



Question 8. What is the use of clog?
  1.    Standard logging stream
  2.    Error stream
  3.    Input stream
  4.    None of the mentioned
Explanation:-
Answer: Option A. -> Standard logging stream


clog is an object of class ostream that represents the standard logging stream. It is associated with the cstdio stream stderr, like cerr.



Question 9. Which operator is used to create the user-defined streams in c++?
  1.    >>
  2.    &
  3.    Both a & b
Explanation:-
Answer: Option C. -> Both a & b


We can make user-defined types with streams by overloading the insertion operator () to read objects from streams.



Question 10. How many types of guarantees are there in exception class can have?
  1.    1
  2.    2
  3.    3
  4.    4
Explanation:-
Answer: Option C. -> 3


There are three types of guarantees in c++. They are weak, strong and no-throw.