UGC NET STUDY MATERIALS

C++ SAMPLE PAPER

===========================================
Model Question Paper

Subject Code: MC0066

Subject Name: OOPs using C++

Credits: 4 Marks: 140
==========================================
Part A (One mark questions)

1. _______________ is an OOP Language.

A. Basic

B. Fortan

C. C++

D. Cobol

2. ---------------- allows you to create a derived class that inherits properties from more than one

base class.

A) Multilevel inheritance

B) Multiple inheritance

C)Hybrid Inheritance

D) Hierarchical Inheritance

3. _______________ feature in OOP allows to reuse code

A) Polymorphism

B) Inheritance

C) Encapsulation

D) Data hiding

4. A class that declares or inherits a virtual function is called -------------------

A) Encapsulation class

B)inherited class

C) polymorphic class

D) static class

5. C++ header file that handles input output functions is ____________

A) iostream.h

B) iomanip.h

C) string.h

D) fstream.h

6. -------------- are bound dynamically at run time.

A) static class

B) virtual function

C) friend function

D) inline function

7. ---------- pointers are not modifiable.

A) that

B) this

C) Indirection

D) Address

8. ---------------- classes are used in cases where one class is tightly coupled to another

class

A) Abstract

B) friend

C) static

D) virtual

9. The extension of C++ source file is _______________

A) .txt

B) .doc

C) .c

D) .cpp

10. The ------------------ keyword/s do not apply to friend functions, as the class has no control

over the scope of friends.

A) public

B) protected

C) private

D) both A) and B)

11. The extension of C++ object code is __________________
A) .obj

B) .cpp

C) .ppt

D) .xls

12. --------------- do not break encapsulation, but rather enhance a class interface.

A) Static functions

B)Friend functions

C) Dynamic functions

D) none of these

13. The function-------------- will return the last read character and will move the inside pointer,

one with -1 char.

A) putback()

B) flush()

C) peek()

D) getline()



14.--------------is an identifier that can be inserted into an output stream or extracted from

an input stream in order to produce a desired effect.

A)Stream

B) Manipulator

C) this

D) Flag

15. The error occuring due to missing semicolon is __________________

A) Syntax

B) Logical

C) Linker

D) Runtime

16. Identify the modulators from the following list.

i. endl ii. hex iii. auto iv. Default

A) i only

B) ii only

C) both i and ii

D) all of these

17. Which of these manipulator is used to insert null character in a string.

A) endl

B) ends

C) unitbuf

D) setfill

18. Which of these file open mode you use to delete all previous content in the file.

A) ios :: ate

B) ios ::in

C) ios:: app

D) ios::trunc

19. A class generated from a class template is called --------------------

A) Inherited class

B) generated class.

C) derived class

D) base class

20. The size of an int variable in C++ is _____________bytes

A) 4.

B) 2

C) 1

D) 8

21. -------------- is very useful when templates of template come into usage.

A) friend function

B) static function

C) typedef

D) inheritance

22. Which of these c++ feature allow you to create classes that are dynamic in terms of the

types of data they can handle.

A) Inheritance

B) Templates

C) Polymorphism

D) information hiding

23. Create the required classes by plugging in the actual type for the type parameters, this

process is commonly known as ------------------------

A) Instantiating a class.

B) encapsulation of class

C) booting of class

D) none of these

24. What are the two basic models in the exception handling theory.

A) caught and uncaught

B) termination and resumption

C) try and block
D) none of these

25. Which of these is/are the exception classes derived from logic_error

i) domain_error ii) out_of_range iii) bad_cast iv) bad_alloc

A) i),ii),iii) only

B) iv) only

C) i) and iv) only

D) iii) only

26. Each catch clause (exception handler) is like a little function that takes a ----------------

argument/s of one particular type.

A) many

B) two

C) single

D) either A) or B)

27. The size of an double variable in C++ is ________________ bytes

A) 10

B) 2

C) 4

D) 8

28. The exception specification is like a----------------, It tells the user to write exception

handling code and what exceptions to handle.

A) library file

B) function prototype

C) header file

D) built-in function

29. Which of these exception reports a failure to allocate storage.

A) bad_cast

B) bad_typeid

C) length_error

D) none of these

30. Stack is an example for ---------------- structure.

A) LIFO

B) FIFO

C) SISO

D) LILO
31. The standard sequence containers include --------------

i) vector ii) deque iii)list iv) stack

A) i) and ii) only

B) i),ii) and iii)

C) iii) and iv) only

D) i),ii),iii) and iv)

32. STL stands for --------------

A) standard template library

B) standard template link

C) stack template link

D) single temporary list

33. Iterators which can move freely any number of steps in one operation are called -------------

A) input iterators

B) forward iterators

C) random access iterators

D) output iterators
34. There are ------------- types of sequence containers in the STL.

A) two

B) four

C) eight

D) three

35. To destroy element at the end of vector which of these vector access function

is used.

A)pop_back()

B) push_back()

C) insert()

D) destroy()

36. --------------- diagram shows the change of an object through time.

A) Activity

B) State

C)Collaboration

D)Use case

37. Which of these link is used to avoid repetition of scenarios in multiple use cases.

A) Include

B) Generalization

C) Extends

D) None of these

38. Models in UML consist of ---------------- that interact by sending each other, messages.

A) Actor

B) objects

C) use case

D) none of these

39. Which one of the following symbols is used for indicating comments?

A) >>

B) <<

C) //

D)**

40. Use case diagrams are helpful in which of these areas.

A) determining failure

B) communicating with clients

C) generating test cases

D) all of these

Part B (Two mark questions)

41. ------------------- is a master function required in all C++ program and execution begins from

the first statement of this function.

A) Virtual function

B) main()

C) inline()

D) getch()

42. ----------------- is the ability of objects belonging to different types to respond to method calls

of methods of the same name, each one according to an appropriate type-specific behavior.

A) Inheritance

B) Virtuality

C) polymorphism

D) None of these.

43. State true or false

1. Inheritance is implemented in C++ through the mechanism of derivation.

2. Multiple inheritance allows you to create a derived class that inherits properties from

more than one base class.

A) true, true

B) true, false

C) false , true

D) false , false

44. State true or false

1. Polymorphic functions are functions that cannot be applied to objects of more than one
type.

2. Overloaded functions are statically bound at run time.

A) false, true

B) false, false

C) true , true

D) true, false

45. -------------- statement takes the control out of the loop.

A) break

B) const

C) continue

D) auto

46. The --------- and ------------------- keywords do not apply to friend functions, as the class has

no control over the scope of friends.

A) public, protected

B) Private, public

C) protected , private

D) private , protected

47. -------------- library function can be used to copy the contents of one string to another string.

A) strcp()

B)strcmp()

C) strcpy()

D) stringcopy()

48. The current reading position, which is the index of the next byte that will be read from

the file is called -----------------------.

A) set pointer

B) curr pointer

C) put pointer

D ) get pointer

49. Which of these function returns the ASCII code of the char, but not the char itself

A) peek()

B) asc()

C) tellg()

D) seekp()

50. To perform identical operations for each type of data compactly and conveniently, we use -------------

A)Inline function

B) function templates.

C) this pointer

D) friend function

51. A static data member generated from a static data member template is called -------static data member

A) inherited

B) base

C) generated

D) derived

52. State true or false

i. You can partially specialize class templates for certain types.

ii. You cannot overload function templates.

A) true, false

B) false, true

C) true, true

D) false, false

53. Default values for the arguments have to be specified during ----------------

A) Initialization

B) Declaration

C) instantiation

D) end of the program

54. Exceptions should not be used for---------------

A) asynchronous events

B) ordinary error condition

C ) flow of control

D) all of the above

55. State true or false

i. C++ provides syntax to allow you to politely tell the user what exceptions this

function throws, so the user may handle them.

ii. To use set_unexpected(), you must include the header file .

A) true , false

B) false, false

C) true, true

D) false, true

56. Which of this is standard associative containers ?

A) vector

B) set

C) deque

D) list

57. The advantage of passing by reference is-------------------------------

A) returning multiple value

B) modifying original values

C) Both A )and B)

D) Neither A) nor B)

58. The operator [] allows you to access a single character in a string, but without any

bounds checking , if you want bounds checking which of these function do you use .

A) at()

B) ioc()

C) st()

D) ooc()

59. Member functions of a class can be defined outside the class using ---------- operator

along with the class name.

A) **

B) &&

C) ::

D) ->

60. Sate true or false

i) Function enable to reuse code.

ii) In if else statement , at any point of time statements in both the if and else part may

be executed.

A) true ,false

B) true , true

C) false , false

D) false, true


Part C (Four mark questions)

61. Write the output of the following C++ code

# include

void main()

{ int x=1;

switch (x)

{

case 0 : cout<<”zero”;

break;

case 1: cout <<“one”;

case 2: cout<

}

}

A) zero

B) one

C) onetwo

D) syntax error

62. What is the output of the following program.

#include

using namespace std;

class Base {

public:

char* name;

void display() {

cout << name << endl;

}

};

class Derived: public Base {

public:

char* name;

void display() {

cout <

}

};

int main() {

Derived d;

d.name = "Derived Class";

d.Base::name = "Base Class";

Derived* dptr = &d;

// standard conversion from Derived* to Base*

Base* bptr = dptr;

// call Base::display()

bptr->display();

}

A) syntax error

B)Base Class

C) Derived Class

D) name

63. Match the following

1. this pointer                                          i) virtual

2. non static member function               ii) not transitive

3. friend function                                  iii) not modifiable

4. Friend class                                       iv) tightly coupled

A) 1-ii,2-I,3-iv,4-iii

B) 1-iii, 2-i, 3-ii, 4-iv

C) 1-iv,2-iii,3-I,4-ii

D) 1-iii,2-iv,3-I,4-ii

64. State true or false

1. A static member function cannot be declared with the keywords virtual, const,volatile,const volatile

2. A static member function can have access to the 'this' pointer of the class.

3. Friend classes are used in cases where one class is tightly coupled to another class.

4. Static data types can be accessed without instantiation of the class in C++.

A) true, true, false, false

B) true, true, true, false

C) true, false, true, true

D) false, true, true, true

65. match the following

1. godbit            i) End of file has been reached

2. eofbit          ii) Fatal I/O error

3. failbit          iii) non-fatal I/O error

4. badbit        iv) no errors

A) 1- ii 2-iii 3-iv 4-I

B) 1-iv 2- i 3-iii 4-ii

C) 1-iii, 2-i 3-iv 4-ii

D) 1- ii, 2- iv 3- iii 4-i

66. State true or false

i. When you are reading a file, if you want to ignore certain amount of characters use flush() function .

ii. Manipulators are global functions designed to be used in conjunction with insertion (<<) and

extraction >>operators.

iii. The essential characteristic of stream processing is that data elements must be sent to or

received from a stream one at a time, i.e. in serial fashion.

iv. The Input/Output system in C++ holds information about the result of every I/O operation.

A) true, true, true, true

B) false, true, true, false

C) false, true, true, true

D) false, true, false, true

67. ------------------------ are very useful when implementing generic constructs like vectors,

stacks, lists, queues which can be used with any arbitrary type.

A) Templates

B) constructor

C ) destructor

D) status Flag

68. Find the output of the following program

//virtual.cpp

# include

class base

{ public:

virtual void show() // virtual function

{cout<<"base”<

class derv1:public base

{ public:

void show()

{cout<<"derv1”<

class derv2: public base

{ public:

void show()

{cout<<“derv2”<

void main()

{

derv1 dv1;

derv2 dv2;

base *ptr;

ptr=&dv1;

ptr->show();

ptr=&dv2;

ptr->show();

}

A) derv 1


     derv2

B) derv2

derv2

C)derv1

derv1

D) syntax error

69. Which of these is/are true about exception specification

i) the exception specification is like function specification

ii) it tells the use to write exception handling code and what exception to handle.

iii) It tells the compiler the exception that may come out of this function.

A) i) only

B) i) and ii) only

C) i),ii) and iii)

D) i) and iii) only

70. State true or false

i. range_error is the exception class derived from logic_error Exception.

ii. bad_cast is the exception class derived from logic_error Exception.

iii. bad_alloc is the exception class derived from runtime_error Exception.

A) true, false, true

B) false, true, true

C) true, true, false

D) true, true, true

71.

Match the following

1. Stack            i) associative container

2. Queue         ii) sequence container

3. Vector       iii) LIFO

4. multimap      iv) FIFO

A) 1-ii, 2-iii, 3-iv, 4-I

B) 1-iii, 2-iv, 3-ii , 4- i

C) 1-iii, 2-iv , 3-i , 4-ii

D) 1-iv, 2-iii, 3-i, 4-ii

72. State true or false

i. STL algorithms are dependent of containers, which significantly reduces the

complexity of the library.

ii. Associative containers are not used to store objects that we want to be able to

retrieve using a key.

iii. Iterators are a generalized abstraction of pointers, designed to allow programmers to

access different container types in a consistent way.

A) false, false , true

B) true, false, false

C) true, true, false

D) true, true, true

73. Match the following

1. polymorphism          i. can be overloaded

2. inheritance              ii. Cannot be overloaded

3. constructor           iii. Reuse of code

4. destructor             iv. Same content different form

A) 1-ii 2-iii 3-iv 4-i

B) 1-iii 2-i 3-ii 4-iv

C) 1-iv 2-iii 3-i 4- ii

D) 1-iii 2-iv 3-i 4-ii

74. state true or false

a. The class diagrams describes the types of objects in the system and the static

relationship between them.

b. If the attribute is declared final its value can be changed.

c. The composition association is represented by the hollow diamond.

A) true ,true, false

B) true, false, false

C) false, false, false

D) false , true, true

75. State true or false

1. Static data need not be initialized.

2. Friend function can be declared anywhere within the class declaration.

3.The public and protected keywords do not apply to friend functions.

A) false, true , true

B) false, true, false

C) true, false , false

D) false, false, false

================================================
                                                 "the end"
================================================



Popular Posts

Recent Posts