Test Series - cpp

Test Number 60/102

Q: What is the Run-Time Type Information?
A. Information about an object’s data type at runtime
B. Information about the variables
C. Information about the given block
D. Information about the functions
Solution: With the help of RTTI, We can get the information about the data type at the runtime.
Q: Which operators are part of RTTI?
A. dynamic_cast()
B. typeid
C. both dynamic_cast<> & typeid
D. dynamic_cast[]
Solution: The dynamic_cast<> operation and typeid operator in C++ are part of RTTI.
Q: To which type of class, We can apply RTTI?
A. Encapsulation
B. Polymorphic
C. Derived
D. Static
Solution: RTTI is available only for classes which are polymorphic, which means they have at least one virtual method.
Q: What is meant by type_info?
A. Used to hold the type information returned by the typeid operator
B. Used to hold the type information returned by the dynamic_cast
C. Used to hold the type information returned by the static_cast
D. Used to hold the type information returned by the static_id
Solution: type_info is used to hold the type information returned by the typeid operator.
Q: At which time does the static_cast can be applied?
A. Compile-time construct
B. Runtime construct
C. Both Compile-time & Runtime construct
D. Runtime deconstruct
Solution: Static_cast can be applied to only compile-time construct and not during run time construct.
Q: Which is referred by pointers to member?
A. Static members of class objects
B. Non-static members of class objects
C. Referring to whole class
D. Dynamic members of class objects
Solution: We cannot use a pointer to member to point to a static class member because the address of a static member is not associated with any particular object.
Q: What should be used to point to a static class member?
A. Smart pointer
B. Dynamic pointer
C. Normal pointer
D. Static pointer
Solution: Normal pointer is sed to point to a static class member.
Q: Which operator is used in pointer to member function?
A. .*
B. ->*
C. Both .* & ->*
D. $*
Solution: The pointer to member operators .* and ->* are used to bind a pointer to a member of a specific class object.
Q: Which is the best design choice for using pointer to member function?
A. Interface
B. Class
C. Structure
D. Block
Solution: Interface is the best design choice for using pointer to member function.
Q: What is the operation for .*?
A. It combines the first operand and the second operand
B. It separates the first operand and the second operand
C. It reduces the data size
D. It combines the first operand and the second operand and terminates third operand
Solution: The binary operator .* combines its first operand, which must be an object of class type, with its second operand, which must be a pointer-to-member type.

You Have Score    /10