Sei sulla pagina 1di 18

1.Delaration a pointer more than once may cause

 
 

A.

Error

B.Abort

C. Trap

D. Null

2.Which one is not a correct variable type in C++?

 

A.

float

B. real

C. int

D. double

3.Which operation is used as Logical 'AND'

 

A.

Operator-&

B. Operator-||

C.

Operator-&&

D. Operator +

4.An expression A.B in C++ means

 

A.

A is member of object B

B. B is member of Object A D. None of these

C.

Product of A and B

5.A C++ code line ends with

 
 

A.

A Semicolon (;)

B. A Fullstop(.)

 

C.

A Comma (,)

D. A Slash (/)

6

function is used to allocate space for array in memory.

 
 

A.

malloc()

B. realloc()

C.

alloc() D. calloc()

7.A pointer pointing to a variable that is not initialized is called

A.

Void Pointer

B. Null Pointer

C.

Empty Pointer

D. Wild Pointer

8.Default constructor has

arguments.

A.

No argument

B. One Argument

C.

Two Argument

D. None of these

9.A class whose objects cannot be created is known as

A.

Absurd Class

B. Dead Class

C.

Super Class

D. Abstract Class

10. Which class allows only one object to be created.

A.

Nuclear Family Class

B. Abstruct Class

C.

Sigleton Class

D. Number Uno Class

11. Reusability of code in C++ is achieved through

A.

Polymorphism

B. Inheritance

C.

Encapsulation

D. Both A and B

12. In CPP, members of a class are

by default.

A.

Public

B. Private

C. Protected

D. Static

13. In C++ Program, inline fuctions are expanded during

A.

Run Time B. Compile Time

C. Debug Time

D.Coding Time

14. To proper file input / output operation in C++, we must include which header file?

A. <fiostream>

B. <ifstream> C. <ofstream> D. <iostream>

15. An exception in C++ can be generated using which keywords.

A. thrown

B. threw

C. throw

D. throws

16. Which of the following type of class allows only one object of it to be created?

A. Virtual class

B. Abstract class

C. Singleton class

D. Friend class

17.

Which of the following is not a type of constructor?

A.

Copy constructor

B. Friend constructor

C.

Default constructor

D. Parameterized constructor

18. Which of the following statements is correct?

A.

Base class pointer cannot point to derived class

B.

Derived class pointer cannot point to base class.

C.

Pointer to derived class cannot be created.

D.

Pointer to base class cannot be created.

19. Which of the following is not the member of class?

A. Static function

B. Friend function C. Const function

D. Virtual function

20. Which of the following concepts means determining at runtime what method to invoke?

A.

Data hiding

B. Dynamic Typing

C.

Dynamic binding D. Dynamic loading

21. The default access specifer for the class members is

A.

public

B. private

C. protected

D. None of the above.

22. A trigraph character begins with

 

A

- #

B - ##

C - ?

D - ??

23. C++ does not supports the following

A

- Multilevel inheritance

B - Hierarchical inheritance

C

- Hybrid inheritance

D - None of the above.

24. One of the following is true for an inline function.

A

- It executes faster as it is treated as a macro internally

B

- It executes faster because it priority is more than normal function.

C

- It doesn’t executes faster compared to a normal function

D

- None of the above holds true for an inline function

25. Choose the pure virtual function definition from the following.

A

- virtual void f=0 { }

B - void virtual f=0 { }

C

- virtual void f {} = 0;

D - None of the above.

26. Abstract class is

A

- A class must contain all pure virtual functions

B

- A class must contain at least one pure virtual function

C

- A class may not contain pure virtual function.

D

- A class must contain pure virtual function defined outside the class.

27. What is the output of the following program? #include<isotream > using nam espace std;

class abc { void f(); void g(); int x;

};

m ain() {

cout<<sizeof(abc)<<endl;

}

A 12

B 4

C 8

D - Compile error

28. What is the output of the following program?

#include<isotream >

using nam espace std; class abc {

public:

static int x;

int i;

abc() {

i

= ++x;

}

 

};

int abc::x;

m ain() {

abc m , n, p;

cout<<m .x<<" "<<m .i<<endl;

}

A - 3 1

B - 3 3

C - 1 1

D - 1 3

29. A constructor can be virtual.

 

A

True

B False

30. Choose the operator which cannot be overloaded.

 

A

- /

B -

C - ::

D - %

31. Which operator is required to be overloaded as member function only?

 

A

- _

B -

C - ++ postfixversion

D - =

32. Which of the following is not the keyword in C++?

A

volatile

B friend

C extends

D - this

33. What is the output of the following program? #include<isotream >

using nam espace std; class abc {

public:

int i;

abc(int i) {

i = i;

}

};

m ain() {

abc m (5); cout<<m .i;

}

A 5

C - Error at the statement i=i;

B Garbage D - Compile error: ‘i’ declared twice.

34. By default the members of the structure are

A

private

B - protected

C

public

D - Access specifiers not applicable for structures.

35. From the below class choose the proper definition of the member function f.

tem plate <class T> class abc { void f();

};

A

- template <class T> void abc<T>::f { }

B - template<class T> void abc::f { }

C

- template<T> void abc<class T>::f { }

D - template<T> void abc<T>::f { }

36. Choose the respective delete operator usage for the expression ‘ptr=new int[100]’.

A

- delete ptr;

B - delete ptr[];

C

- delete[] ptr;

D - []delete ptr;

37. ‘cin’ is an

A Class

B Object

C Package

D - Namespace

38. The operator used to access member function of a structure using its object.

A - .

B - ->

C - *

D - None of the above.

39. A user defined header file is included by following statement in general.

A - #include “file.h”

- #include <file.h>

C - #include <file>

D - #include file.h

40. Which data type can be used to hold a wide character in C++?

A - unsigned char;

B int

C - wchar_t

D - none of the above.

41. Which is the storage specifier used to modify the member variable even though

the class object is a constant object?

A auto

B register

C static

D - mutable

42 - The following operator can be used to calculate the value of one number raised to another.

A - ^

B - **

C - ^^

D -None of the above

43. Pick up the valid declaration for overloading ++ in postfix form where T is the

class name.

A

- T operator++;

B - T operator++int;

C

- T& operator++;

D - T& operator++int;

44. We can have varying number of arguments for the overloaded form of

operator.

A True

B False

45. Operators sizeof and ?:

A

- Both can be overloaded

B - Both cannot be overloaded

C

- Only sizeof can be overloaded

D - Only ?: can be overloaded

46. What is the output of the following program? #include<isotream > using nam espace std;

m ain() {

int i = 1, j = 2, k = 3, r; r = (i, j, k);

cout<<r<<endl;

 

}

A

1

B 2

C 3

D - Compile Error

47. In the following program f is overloaded.

void f(int x) {

}

void f(signed x) {

}

m

ain() {

}

A

True

B - False

48. In the following program f is overloaded. void f(int x) {

}

int f(signed x) { return 1;

}

m

ain() {

}

A

True

B - False

49. A protected member of the class in accessible in

A

- Only same class

B - Same class and derived class

C

- Outside the class

D - None of the above.

50. Runtime polymorphism is done using.

A - Function overloading

C - Virtual functions

B - Virtual classes D - Friend function

51. Choose the Object oriented programming language from below.

A - C++

B - Small talk

C Simula

D - All the above.

52. Class function which is called automatically as soon as the object is created is

called as

A

Constructor

B Destructor

C

- Friend function

D - Inline function.

53. Escape sequence character '\0' occupies

A 0

B 1

C 2

amount of memory. D - 4

54. How can we make an class act as an interface in C++?

A

- By only providing all the functions as virtual functions in the class.

B

- Defining the class following with the keyword virtual

C

- Defining the class following with the keyword interface

D

- Defining the class following with the keyword abstract

55. The pointer which stores always the current active object address is

A - auto_ptr

B this

C p

D - none of the above.

56. We can use this pointer in static member function of the class.

A True

B False

57. Designer of C++ programming language.

A

- Charles Babbage

B - Dennis Ritchie

C

- Brain Kernighan

D - Bjarne Stroustrup

58. How many number of arguments can a destructor of a class receives?

A 0

B 1

C 2

D - None of the above.

59. What is the output of the following program?

#include<isotream > using nam espace std; class Base {

public:

virtual void f() {

cout<<"Base\n";

}

};

class Derived:public Base {

public:

void f() {

cout<<"Derived\n";

}

};

m ain() {

Base * p = new Derived(); p->f();

}

A

Base

B Derived

C - Compile error

D - None of the above.

60. What is the output of the following program? #include<isotream >

using nam espace std; class Base {

public:

void f() {

cout<<"Base\n";

}

};

class Derived:public Base {

public:

f() {

cout<<"Derived\n";

}

};

m ain() {

Base * p = new Derived();

p->f();

}

A Base

B Derived

C - Compile error

61. What is the output of the following program?

#include<isotream > using nam espace std; class Base {

public:

void f() {

cout<<"Base\n";

}

};

class Derived:public Base {

public:

void f() {

cout<<"Derived\n";

}

};

D - None of the above.

m

ain() {

Derived obj;

 

obj.Base::f();

}

A Base

B Derived

C - Compile error

D - None of the above.

62. What is the output of the following program? #include<isotream >

using nam espace std; class Base {

public:

void f() {

cout<<"Base\n";

}

};

class Derived:public Base {

public:

void f() {

cout<<"Derived\n";

};

};

m

ain() {

Derived obj;

 

obj.Base::f();

}

A Base

B Derived

C - Compile error

D - None of the above.

63. What is the output of the following program?

#include<isotream > using nam espace std;

m ain() {

int * p = new int;

delete p;

delete p;

cout<<"Done";

 

}

A

Done

B - Compile error

C - Runtime error

D - None of the above

64. What is the output of the following program? #include<isotream > using nam espace std;

m ain() {

int const a = 5;

 

a++;

cout<<a;

}

A

5

B 6

C - Runtime error

D - Compile error

65. Which operator is used to resolve the scope of the global variable?

A - −>

B - .

C - *

D - ::

66. Which feature of the OOPS gives the concept of reusability?

A

Abstraction

B - Encapsulation

C

Inheritance

D - None of the above.

67. Objects created using new operator are stored in

A Cache

B Heap

C Stack

68. What is the full form of RTTI.

memory.

D - None of the above.

A

- Runtime type identification

B - Runtime template identification

C

- Robust Template Type Inheritance

D - None of the above.

69. The programs machine instructions are store in

memory segment.

A Data

B Stack

C Heap

D - Code

70. The copy constructor is executed on

A - Assigned one object to another object at its creation

B - When objects are sent to function using call by value mechanism

C - When the function return an object

D - All the above.

71. Choose the option not applicable for the constructor.

A

- Cannot be called explicitly.

B - Cannot be overloaded.

C

- Cannot be overridden.

D - None of the above.

72. An array can be passed to the function with call by value mechanism.

A True

B - False

73. A C++ program statements can be commented using

A

- Single line comment

B - Multi line comment

C

- Either a or b

D - Both a and b.

74. HAS-A relationship between the classes is shown through.

A Inheritance

75. What is a generic class.

B - Container classes

A

- Function template

B - Class template

C

- Inherited class

D - None of the above.

76. What is the full form of STL?

A

- Standard template library.

B - System template library.

C

- Standard topics library.

D - None of the above.

77. Which type of data file is analogous to an audio cassette tape?

A

- Random access file

B - Sequential access file

C

- Binary file

D - Source code file

78. i) single file can be opened by several streams simultaneously.

ii) several files simultaneously can be opened by a single stream

A

- i and ii are true

B - i and ii are false

C

- Only i is true

D - Only ii is true

79.

With respective to streams >> operator is called as

 
 

A

- Insertion operator

B - Extraction operator

C

- Right shift operator

D - Left shift operator

80.

i ‘ios’ is the base class of ‘istream’

ii All the files are classified into only 2 types. 1 Text Files 2 Binary Files.

 

A

- Only i is true

B - Only ii is true

C

- Both i & ii are true

D - Both i & ii are false

82.

An exception is

 
 

A

- Runtime error

B - Compile time error

C

- Logical error

D - None of the above

83.

i) Exception handling technically provides multi branching.

 

ii) Exception handling can be mimicked using ‘goto’ construct.

 

A

- Only i is true

B - Only ii is true

C

- Both i & ii are true

D - Both i && ii are false

84.

What is the output of the following program?

 
 

#include<isotream >

 

using nam espace std;

m

ain()

{

const int a = 5;

 

a++;

cout<<a;

}

A

5

B 6

C - Runtime error

D - Compile error

85.

What is the output of the following program? #include<isotream > using nam espace std;

 

m

ain()

{

char s[] = "hello", t[] = "hello";

 

if(s==t) cout<<"eqaul strings";

}

A

- Equal strings

B - Unequal strings

C

- No output

D - Compilation error

86.

What is the outpout of the following program?

 

#include<isotream > using nam espace std;

m ain()

{

enum { india, is = 7, GREAT

};

cout<<india<<” “<<GREAT;

}

A

- 0 1

B - 0 2

C - 0 8

D - Compile error

87. What is the output of the following program?

#include<isotream >

using nam espace std;

m ain()

{

short unsigned int i = 0;

cout<<i--;

 

}

A 0

B - Compile error

C 65535

D - 32767

88. What is the output of the following program? #include<isotream > using nam espace std;

 

m

ain()

{

int x = 5;

 

if(x==5)

{

if(x==5) break;

 

cout<<"Hello";

}

cout<<”Hi”;

 

}

A - Compile error

B Hi

C HelloHi

D - Hello

89. What is the output of the following program?

#include<isotream > using nam espace std; void f() { static int i;

++i;

cout<<i<<” “;

}

m

ain()

{

f();

f();

f();

}

A - 1 1 1

B - 0 0 0

C - 3 2 1

D - 1 2 3

90. What is the output of the following program? #include<isotream > using nam espace std;

void f() {

cout<<”Hello”<<endl;

}

m

ain()

{

}

A - No output

B - Error, as the function is not called.

C - Error, as the function is defined without its declaration

D - Error, as the main function is left empty

91. What is the output of the following program? #include<isotream > using nam espace std;

m

ain()

{

int x = 1; switch(x)

{

default: cout<<”Hello”;

case 1: cout<<”Hi”; break;

}

}

A

Hello

B Hi

C HelloHi

D - Compile error

92. What is the output of the following program?

#include<isotream > using nam espace std;

void swap(int m , int n)

{

int x = m ;

m = n;

n = x;

}

m ain()

{

int x = 5, y = 3; swap(x,y); cout<<x<<” “<<y;

}

A - 3 5

B - 5 3

C - 5 5

D - Compile error

93. What will be the output of the following program?

#include<isotream > #include<string.h>

using nam espace std;

m ain()

{

cout<<strcm p("strcm p()","strcm p()");

}

A 0

B 1

C - -1

D - Invalid use of strcmp function

94. What is the output of the following program?

#include<isotream >

using nam espace std;

m

ain()

{

int r, x = 2; float y = 5; r = y%x;

cout<<r;

}

A 1

B 0

C 2

D - Compile error

95. What is the size of the following union definition? #include<isotream >

using nam espace std;

m ain()

{

union abc { char a, b, c, d, e, f, g, h;

int i;

};

cout<<sizeof(abc);

}

A

1

B 2

C 4

D - 8

96. What is the size of ‘int’?

 

A

2

B 4

C 8

D - Compiler dependent

97. What is the output of the following program? #include<isotream > using nam espace std;

m

ain()

{

float t = 2;

switch(t)

{

case 2: cout<<”Hi”; default: cout<<"Hello";

}

}

A

Hi

B HiHello

C Hello

D - Error

98. What is the output of the following program?

#include<isotream >

using nam espace std;

m ain()

{

int a[] = {1, 2}, * p = a;

cout<<p[1];

}

A 1

B 2

C - Compile error

D - Runtime error

99. What is the output of the following program?

#include<isotream >

using nam espace std;

m ain()

{

int i = 13, j = 60;

i^=j;

j^=i;

i^=j;

cout<<i<<” “<<j;

}

A

- 73 73

B - 60 13

C - 13 60

D - 60 60

100. What is the output of the following program? #include<isotream >

using nam espace std;

m

ain()

{

union abc {

int x;

char ch;

} var;

var.ch = 'A'; cout<<var.x;

}

A A

B - Garbage value

file

101. Compiler generates

C 65

D - 97

A

- Executable code

B - Object code

C

- Assembly code

D - None of the above.

102. Special symbol permitted with in the identifier name.

A - $

B - @

C - _

D - .

103. A single line comment in C++ language source code can begin with

A - ;

B - :

C - /*

D - //

104. An inline function can execute faster than a normal function.

A True

B False

105. Choose the invalid identifier from the below

A Int

B bool

106. Identify the C++ compiler of Linux

A cpp

B - g++

C DOUBLE

C Borland

D -

0

D - vc++

107. Following is the invalid inclusion of a file to the current program. Identify it

A - #include <file>

B - #include < file

C - All of the above are invalid

108. What is the output of the following program?

#include<isotream >

using nam espace std; int x = 5; int& f() { return x;

}

m

ain() {

f() = 10;

cout<<x;

}

A 5

B - Address of ‘x’

C - Compile error

D - 10

109. The default executable generation on UNIX for a C++ program is

A - a.exe

B a

C - a.out

D - out.a

110. What is the output of the following program? #include<isotream > using nam espace std; void f() {

static int i = 3;

cout<<i;

if(--i) f();

}

m

ain() {

f();

}

A

- 3 2 1 0

B - 3 2 1

C - 3 3 3

D - Compile error

111. What is the output of the following program?

m

ain() {

}

A

- No output

B Garbage

C - Compile error

D - Runtime error

112. Does both the loops in the following programs prints the correct string length? #include<isotream > using nam espace std;

m ain()

{

int i; char s[] = "hello";

for(i=0; s[i]; ++i);

cout<<i<<endl;

 

i=0;

while(s[i++]);

cout<<i;

}

A

- Yes, both the loops prints the correct length

B

- Only for loop prints the correct length

C

- Only while loop prints the correct length

D

- Compile error in the program.

113. What is the output of the following program?

#include<isotream > using nam espace std;

m ain()

{

int a[] = {10, 20, 30}; cout<<* a+1;

}

A

10

B 20

C 11

D - 21

114. What is the output of the following program? #include<isotream >

using nam espace std;

m ain()

{

char s[] = "Fine";

* s = 'N';

cout<<s<<endl;

 

}

A

Fine

B Nine

C - Compile error

D - Runtime error

115. What is the output of the following program? #include<isotream > using nam espace std;

m ain()

{

char * s = "Fine";

* s = 'N';

cout<<s<<endl;

 

}

A

Fine

B Nine

C - Compile error

D - Runtime error

116. What is the built in library function to compare two strings?

A

- string_cmp

B strcmp

C equals

D - str_compare

117. - What is the output of the following program?

 

#include<isotream > using nam espace std; void m ain()

 

{

char * s = "C++"; cout<<s<<" ";

 

s++;

cout<<s<<" ";

}

A

- C++ C++

B - C++ ++

C - ++ ++

D - Compile error

118. What is the output of the following program?

#include<isotream >

using nam espace std; void m ain()

{

char s[] = "C++"; cout<<s<<" ";

s++;

cout<<s<<" ";

}

A - C++ C++

B - C++ ++

C - ++ ++

119. What is the output of the following program?

#include<isotream >

#include<string.h> using nam espace std;

m ain()

{

char s[]="Hello\0Hi"; Cout<<strlen(s)<<” “<<sizeof(s);

D - Compile error

}

A - 5 9

B - 7 20

C - 5 20

D - 8 20

120. What is the output of the following program? #include<isotream > using nam espace std;

m

ain()

{

class student

 

{

int rno = 10; } v; cout<<v.rno;

 

}

A

10

B Garbage

C - Runtime error

D - Compile error

121. i) Exceptions can be traced and controlled using conditional statements. ii) For critical exceptions compiler provides the handler

A

- Only i is true

B - Only ii is true

C

- Both i & ii are true

D - Both i && ii are false