Q.61 An array element is accessed using
(A) a FIFO approach (B) an index number
(C) the operator (D) a member name
Ans:B
Q.62 If there is a pointer p to object of a base class and it contains the address of an object of a
derived class and both classes contain a virtual member function abc(), then the statement
p->abc(); will cause the version of abc() in the __________class to be executed.
(A) Base Class (B) Derived class
(C) Produces compile time error (D) produces runtime error
Ans:B
Q.63 A pure virtual function is a virtual function that
(A) has no body (B) returns nothing
(C) is used in base class (D) both (A) and (C)
Ans:D
Q.64 A static function
(A) should be called when an object is destroyed.
(B) is closely connected with and individual object of a class.
(C) can be called using the class name and function name.
(D) is used when a dummy object must be created.
Ans:C
Q.65 We can output text to an object of class ostream using the insertion operator<< because
(A) the ostream class is a stream
(B) the insertion operator works with all classes.
(C) we are actually outputting to cout.
(D) the insertion operator is overloaded in ostream.
Ans:D
Q.66 The statement f1.write((char*)&obj1, sizeof(obj1));
(A) writes the member function of obj1 to f1.
(B) Writes the data in obj1 to f1.
(C) Writes the member function and the data of obj1 to f1.
(D) Writes the address of obj1 to f1.
Ans:B
Q.67 To convert from a user defined class to a basic type, you would most likely use.
(A) A built-in conversion function.
(B) A one-argument constructor.
(C) A conversion function that’s a member of the class.
(D) An overloaded ‘=‘ operator.
Ans:C
Q.68 Which of the following is not the characteristic of constructor.
(A) They should be declared in the public section.
(B) They do not have return type.
(C) They can not be inherited.
(D) They can be virtual.
Ans:D
Q.69 Name the header file to be included for the use of built in function isalnum()
(A) string.h (B) process.h
(C) ctype.h (D) dos.h
Ans:C
Q.70 What is the output of given code fragment?
int f=1, i=2;
while(++i<5)
f* =i;
cout<<f;
(A) 12 (B) 24
(C) 6 (D) 3
Ans:A
Q.71 A class defined within another class is:
(A) Nested class (B) Inheritance
(C) Containership (D) Encapsulation
Ans:A
Q.72 What will be the values of x, m and n after the execution of the following statements?
int x, m, n;
m = 10;
n = 15;
x = ++m + n++;
(A) x=25, m=10, n=15 (B) x=26, m=11, n=16
(C) x=27, m=11, n=16 (D) x=27, m=10, n=15
Ans:B
Q.73 Which of the following will produce a value 10 if x = 9.7?
(A) floor(x) (B) abs(x)
(C) log(x) (D) ceil(x)
Ans:D
Q74 The major goal of inheritance in c++ is:
(A) To facilitate the conversion of data types.
(B) To help modular programming.
(C) To extend the capabilities of a class.
(D) To hide the details of base class.
Ans:C
Q.75 Consider the following class definitions:
class a
{
};
class b: protected a
{
};
What happens when we try to compile this class?
(A) Will not compile because class body of a is not defined.
(B) Will not compile because class body of b is not defined.
(C) Will not compile because class a is not public inherited.
(D) Will compile successfully.
Ans:D
C++ MCQ-14
- Details
- Category: C and C++ Programming Language
- Hits: 4112