Two mark Questions
1. Which of the following functions belong to ifstream
i) get( ) ii) gets( ) iii) getline( ) iv) read( )
v) write( ) vi) put( )
a. I, ii, iii, iv b. I, iii, iv c. v, vi d. All
2. Which of the following functions belong to ofstream
i)get( ) ii) gets( ) iii) getline( ) iv) read( )
v)write( ) vi) put
a. I, ii, iii, iv b. I,iii, iv c. v, vi d. All
3. Which of the following are functions in fstream for binary reading and writing
i) get( ) ii) gets( ) iii) getline( ) iv) read( )
v) write( ) vi) put( )
a. iv, v b. I,ii,iii c. v, vi d. All
4. Which of the following are true for friend functions:
i) They do not belong to the class
ii) They belong to a class
iii) they are not transitive
iv) friendship can be inherited
a. ii, ii, iv b. I, iii, iv c. All d. None
5. seekg is for ____ and seekp is for _____
a) getpointer, putpointer b) putpointer,getpointer c) None
6. What is the prototype of the overloaded >> operator.
a. istream& operator>>(istream&, datatype&); b. ostream& operator<<(ostream&, datatype&);
c. istream& operator<<(istream&, datatype&); d. None
7. The feature of OOPs overrules the data – hiding concept are:
i) public members of a class
ii)friend functions and friend classes
a. only I b. only ii c. I, ii d. None
8. Which of the following are true for polymorphism
i) The ability to access different implementations of a function using the same name
ii) They overrule the concept of data-hiding
iii) There are two types of polymorphism : Dynamic & Static
a. only I b. I,iii c. All d. None
9. Which of the following is true for pointers to classes:
i) A pointer to base class can point to base class object as well as derived class object
ii) A pointer to derieved class can point to only its own object
a. Only I b. Only ii c. Both d. None
10. Which of the following are true for virtual functions:
i) The structure of virtual function in the base class and in the derived class is identical
ii) The keyword “virtual” is given only to base class function
iii) The “ virtual” keyword must be used even when redefining the function in the derived class
a. Only I,ii b. only I, iii c. All d. None
11. Give the syntax of declaring pure virtual functions:
a. virtual void fun()=0 b. pure virtual void fun( ){ } c. virtual void fun( ){ } d. None
12. Which of the following is true for pure virtual functions.
i) There is no implementation in the base class
ii) They are always initialized with 0
iii) The class containing this function becomes an abstract class
iv) when deriving the child class must override these functions.
a. only ii, iii b. I, iv c. All d. None
13. Which are the key words used in exception handling in C++:
i) try ii) throw iii) throws iv) catch
a. I, ii, iv b. I, ii c. All d. None
Answer – 2 Marks
1. b 2. c 3. a 4.b 5.b 6.a 7.c 8.b 9.c
10.a 11.a 12.c 13.a