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

1.       The purpose for mode “w+b” in file operation is
(A) create a binary file for write
(B) create a binary file for read/write
(C) open a binary file for writing
(D) open a binary file for reading/writing
Answer: B
2.       A template class
(A) is designed to be stored in different containers
(B) works with different data types
(C) generates objects which must be identical
(D) generates classes with different numbers of member functions.
Answer: B
3.       Which of the following is the valid class declaration header for the derived class d with base classes b1 and b2?
(A) class d : public b1, public b2
(B) class d : class b1, class b2
(C) class d : public b1, b2
(D) class d : b1, b2
Answer: A
4.       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.
Answer: D
5.       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.
Answer: B

6.       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.
Answer: C
7.       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.
Answer: D
8.       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
Answer: C
9.       What is the output of given code fragment?
int f=1, i=2;
(A) 12 (B) 24
(C) 6 (D) 3
Answer: A
10.    A class defined within another class is:
(A) Nested class
(B) Inheritance
(C) Containership
(D) Encapsulation
Answer: A

Post a Comment