Test Series - cpp

Test Number 57/102

Q: Which header file is used to declare the standard exception?
A. #include
B. #include
C. #include
D. #include
Solution: #include is used to declare the standard exception.
Q: Where are standard exception classes grouped?
A. namespace std
B. error
C. catch
D. final
Solution: As these are standard exceptions, they need to be defined in the standard block, So it is defined under namespace std.
Q: How many types of standard exception are there in c++?
A. 9
B. 5
C. 6
D. 7
Solution: There are nine standard exceptions in c++. They are bad_alloc, bad_cast, bad_exception, bad_function_call, bad_typeid, bad_weak_ptr, ios_base::failure, logic_error and runtime_error.
Q: Which of the following is best to include under try block?
A. static values
B. const values
C. dynamic allocations
D. default values
Solution: Because the dynamic allocations can change at any time, So it is best to include in try block.
Q: What are the predefined exceptions in c++?
A. Memory allocation errors
B. I/O errors
C. Both Memory allocation errors & I/O errors
D. static errors
Solution: Both Memory allocation errors & I/O errors are the predefined exceptions in c++.
Q: What will happen when introduce the interface of classes in a run-time polymorphic hierarchy?
A. Separation of interface from implementation
B. Merging of interface from implementation
C. Separation of interface from debugging
D. Merging of interface from debugging
Solution: Separation of interface from implementation introduce the interface of classes in a run-time polymorphic hierarchy.
Q: Which classes are called as mixin?
A. Represent a secondary design
B. Classes express functionality which represents responsibilities
C. Standard logging stream
D. Represent a priary design
Solution: A class that expresses functionality rather than its primary design role is called a mixin.
Q: What is the use of clog?
A. Standard logging stream
B. Error stream
C. Input stream
D. output stream
Solution: clog is an object of class ostream that represents the standard logging stream. It is associated with the cstdio stream stderr, like cerr.
Q: Which operator is used to create the user-defined streams in c++?
A. >>
B. <<
C. &
D. Both >> & <<
Solution: We can make user-defined types with streams by overloading the insertion operator (<<) to put objects into streams and the extraction operator (>>) to read objects from streams.
Q: What does the cerr represent?
A. Standard error stream
B. Standard logging stream
C. Input stream
D. Output stream
Solution: cerr is an object of class ostream that represents the standard error stream. It is associated with the cstdio stream stderr.

You Have Score    /10