Friday, 4 November 2016

C & C++ Programming Multiple Choice Questions - Set 32

1.       If X is the name of the class, what is the correct way to declare copy constructor of X?
(A) X(X arg)                               (B) X(X* arg)
(C) X(const X* arg)                  (D) X(const X& arg)
Answer: D
2.       Which of the following operator cannot be overloaded?
(A) = (assignment operator)
(B) == (equality operator)
(C) -> (rrow operator)
(D) :: (cope resolution operator)
Answer: D
3.       Which of the following operators can be overloaded?
(A) .(dot or member access operator)
(B) & (address-of operator)
(C) sizeof operator
(D) ?: (conditional operator)
Answer: B
4.       How do we declare an abstract class?
(A) By providing at least one pure virtual method in a class
(B) By declaring at least one method abstract using the keyword abstract in a class
(C) By declaring the class abstract with the keyword abstract
(D) It is not possible to create abstract classes in C++
Answer: A
5.       Consider the following statements:
x = 5;
y = x >3 ? 10 : 20;
The value of y is
(A) 10                 (B) 20
(C) 5                   (D) 3
Answer: A
Since x=5 is greater than 3 so y is assigned value 10. It is equivalent to if-else statements.
6.       Determine which of the following is an invalid character constant.
(A) ‘\a’                (B) ‘T’
(C) ‘\0’                (D) ‘/n’
Answer: D
newline character constant is “\n” not “/n”.
7.       When is std::bad_alloc exception thrown?
(A) When new operator cannot allocate memory
(B) When alloc function fails
(C) When type requested for new operation is considered bad, this exception is thrown
(D) When delete operator cannot delete teh allocated (corrupted) object
Answer: A
8.       Which header file should we include for using std::auto_ptr?
(A) <memory>               (B) <alloc>
(C) <autoptr>                (D) <smartptr>
Answer: A
9.       Which of the following correctly describes the meaning of namespace feature in C++?
(A) Namespaces refer to the memory space allocated for names used in a program
(B) Namespaces refer to space between the names in a program
(C) Namespaces refer to space between the names in a program
(D) Namespaces provide facilities for organizing the names in a program to avoid name         clashes
Answer: D
10.    The eof() is the function used for ..............
(A) asserting no errors in a file
(B) appending data to a file
(C) counting the amount of data in a file
(D) checking for end of file
Answer: D


Post a Comment

UGC NET Computer Science

Computer GK App