Вы находитесь на странице: 1из 26

C++ one marks

1.

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

Answer: Option C
2.

Which of the following is not a type of constructor?

A.

Copy constructor

B.

Friend constructor

C.

Default constructor

D.

Parameterized constructor

Answer: Option B
3.

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.

Answer: Option B
4.

Which of the following is not the member of class?

A.

Static function

B.

Friend function

C.

Const function

D.

Virtual function

Answer: Option B

5.
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

Answer: Option C
6.

Which of the following term is used for a function defined inside a class?

A.

Member Variable

B.

Member function

C.

Class function

D.

Classic function

Answer: Option B
7.
Which of the following concept of oops allows compiler to insert arguments in
a function call if it is not specified?
A.

Call by value

B.

Call by reference

C.

Default arguments

D.

Call by pointer

Answer: Option C
8.

How many instances of an abstract class can be created?

A.

B.

C.

13

D.

Answer: Option D
9.

Which of the following cannot be friend?

A.

Function

B.

Class

C.

Object

D.

Operator function

Answer: Option C
10.
Which of the following concepts of OOPS means exposing only necessary
information to client?
A.

Encapsulation

B.

Abstraction

C.

Data hiding

D.

Data binding

Answer: Option C
11.

Why reference is not same as a pointer?

A.

A reference can never be null.

B.

A reference once established cannot be changed.

C.

Reference doesn't need an explicit dereferencing mechanism.

D.

All of the above.

Answer: Option D
12.

cout is a/an __________ .

A.

operator

B.

function

C.

object

D.

macro

Answer: Option C

13.
Which of the following concepts provides facility of using object of one class
inside another class?

A.

Encapsulation

B.

Abstraction

C.

Composition

D.

Inheritance

Answer: Option C
14.

How many types of polymorphisms are supported by C++?

A.

B.

C.

D.

Answer: Option B
15.

Which of the following is an abstract data type?

A.

int

B.

double

C.

string

D.

Class

Answer: Option D
16.
Which of the following concepts means adding new components to a program
as it runs?
A.

Data hiding

B.

Dynamic typing

C.

Dynamic binding

D.

Dynamic loading

Answer: Option D
17.

Which of the following statement is correct?

A.

A constructor is called at the time of declaration of an object.

B.

A constructor is called at the time of use of an object.

C.

A constructor is called at the time of declaration of a class.

D.

A constructor is called at the time of use of a class.

Answer: Option A
18.

Which of the following correctly describes overloading of functions?

A.

Virtual polymorphism

B.

Transient polymorphism

C.

Ad-hoc polymorphism

D.

Pseudo polymorphism

Answer: Option C
19.

Which of the following approach is adapted by C++?

A.

Top-down

B.

Bottom-up

C.

Right-left

D.

Left-right

Answer: Option B
20.

Which of the following is correct about function overloading?

A.

The types of arguments are different.

B.

The order of argument is different.

C.

The number of argument is same.

D.

Both A and B.

21.

Which of the following is correct about class and structure?

A.

class can have member functions while structure cannot.

B.

class data members are public by default while that of structure are private.

C.

Pointer to structure or classes cannot be declared.

D.
class data members are private by default while that of structure are public
by default.
Answer: Option D

22.
Which of the following concepts means wrapping up of data and functions
together?
A.

Abstraction

B.

Encapsulation

C.

Inheritance

D.

Polymorphism

Answer: Option B
23.
Which of the following concepts means waiting until runtime to determine
which function to call?
A.

Data hiding

B.

Dynamic casting

C.

Dynamic binding

D.

Dynamic loading

Answer: Option C
24.

How "Late binding" is implemented in C++?

A.

Using C++ tables

B.

Using Virtual tables

C.

Using Indexed virtual tables

D.

Using polymorphic tables

Answer: Option B
25.

Which of the following operator is overloaded for object cout?

A.

>>

B.

<<

C.

D.

Answer: Option B
26.

Which of the following is the correct class of the object cout?

A.

iostream

B.

istream

C.

ostream

D.

ifstream

Answer: Option C
27.

Which of the following cannot be used with the keyword virtual?

A.

class

B.

member functions

C.

constructor

D.

destructor

Answer: Option C
28.

Which of the following functions are performed by a constructor?

A.

Construct a new class

B.

Construct a new object

C.

Construct a new function

D.

Initialize objects

Answer: Option D
29.

Which of the following problem causes an exception?

A.

Missing semicolon in statement in main().

B.

A problem in calling function.

C.

A syntax error.

D.

A run-time error.

Answer: Option D
30.
Which one of the following options is correct about the statement given
below? The compiler checks the type of reference in the object and not the type of
object.
A.

Inheritance

B.

Polymorphism

C.

Abstraction

D.

Encapsulation

Answer: Option B
31.

Which of the following is the correct way of declaring a function as constant?

A.

const int ShowData(void) { /* statements */ }

B.

int const ShowData(void) { /* statements */ }

C.

int ShowData(void) const { /* statements */ }

D.

Both A and B

Answer: Option C
32.

Which of the following concepts is used to implement late binding?

A.

Virtual function

B.

Operator function

C.

Const function

D.

Static function

Answer: Option A
33.

Which of the following statement is correct?

A.

C++ allows static type checking.

B.

C++ allows dynamic type checking.

C.

C++ allows static member function be of type const.

D.

Both A and B.

Answer: Option D
34.
Which of the following factors supports the statement that reusability is a
desirable feature of a language?
A.

It decreases the testing time.

B.

It lowers the maintenance cost.

C.

It reduces the compilation time.

D.

Both A and B.

Answer: Option D
35.
Which of the following ways are legal to access a class data member using
this pointer?
A.

this->x

B.

this.x

C.

*this.x

D.

*this-x

Answer: Option A
36.

Which of the following is a mechanism of static polymorphism?

A.

Operator overloading

B.

Function overloading

C.

Templates

D.

All of the above

Answer: Option D
37.

Which of the following is correct about the statements given below?

All operators can be overloaded in C++.


We can change the basic meaning of an operator in C++.
A.

Only I is true.

B.

Both I and II are false.

C.

Only II is true.

D.

Both I and II are true.

Answer: Option B
38.
What happens if the base and derived class contains definition of a function
with same prototype?
A.

Compiler reports an error on compilation.

B.

Only base class function will get called irrespective of object.

C.

Only derived class function will get called irrespective of object.

D.
Base class object will call base class function and derived class object will call
derived class function.
Answer: Option D
39.

Which of the following are available only in the class hierarchy chain?

A.

Public data members

B.

Private data members

C.

Protected data members

D.

Member functions

Answer: Option C
40.

Which of the following is not a type of inheritance?

A.

Multiple

B.

Multilevel

C.

Distributive

D.

Hierarchical

Answer: Option C
41. Which of the following operators cannot be overloaded?
A.

[]

B.

->

C.

?:

D.

Answer: Option C
42.

In which of the following a virtual call is resolved at the time of compilation?

A.

From inside the destructor.

B.

From inside the constructor.

C.

From inside the main().

D.

Both A and B.

Answer: Option D
43.

Which of the following statements regarding inline functions is correct?

A.

It speeds up execution.

B.

It slows down execution.

C.

It increases the code size.

D.

Both A and C.

Answer: Option D
44.
Which one of the following is the correct way to declare a pure virtual
function?
A.

virtual void Display(void){0};

B.

virtual void Display = 0;

C.

virtual void Display(void) = 0;

D.

void Display(void) = 0;

Answer: Option C
45.

Which of the following header file includes definition of cin and cout?

A.

istream.h

B.

ostream.h

C.

iomanip.h

D.

iostream.h

Answer: Option D
46.

Which of the following keyword is used to overload an operator?

A.

overload

B.

operator

C.

friend

D.

override

Answer: Option B

47.

What will happen if a class is not having any name?

A.

It cannot have a destructor.

B.

It cannot have a constructor.

C.

It is not allowed.

D.

Both A and B.

Answer: Option D
48.

Which inheritance type is used in the class given below?

class A : public X, public Y


{}
A.

Multilevel inheritance

B.

Multiple inheritance

C.

Hybrid inheritance

D.

Hierarchical Inheritance

Answer: Option B
49.

Which one of the following is correct about the statements given below?

All function calls are resolved at compile-time in Procedure Oriented


Programming.
All function calls are resolved at compile-time in OOPS.

A.

Only II is correct.

B.

Both I and II are correct.

C.

Only I is correct.

D.

Both I and II are incorrect.

Answer: Option C
50.

Which of the following is an invalid visibility label while inheriting a class?

A.

public

B.

private

C.

protected

D.

friend

Answer: Option D
51.

Which one of the following options is correct?

A.

Friend function can access public data members of the class.

B.

Friend function can access protected data members of the class.

C.

Friend function can access private data members of the class.

D.

All of the above.

Answer: Option D
52.

Which of the following statements is correct in C++?

A.

Classes cannot have data as protected members.

B.

Structures can have functions as members.

C.

Class members are public by default.

D.

Structure members are private by default.

Answer: Option B

53.

Which of the following is used to make an abstract class?

A.

Declaring it abstract using static keyword.

B.

Declaring it abstract using virtual keyword.

C.

Making at least one member function as virtual function.

D.

Making at least one member function as pure virtual function.

Answer: Option D
54.
Which of the following access specifier is used as a default in a class
definition?
A.

protected

B.

public

C.

private

D.

friend

Answer: Option C
55.

What is correct about the static data member of a class?

A.

A static member function can access only static data members of a class.

B.

A static data member is shared among all the object of the class.

C.

A static data member can be accessed directly from main().

D.

Both A and B.

Answer: Option D
56. Which of the following provides a reuse mechanism?
A.

Abstraction

B.

Inheritance

C.

Dynamic binding

D.

Encapsulation

Answer: Option B

57.

Which of the following statement is correct?

A.

Class is an instance of object.

B.

Object is an instance of a class.

C.

Class is an instance of data type.

D.

Object is an instance of data type.

Answer: Option B
58.

The address of a variable temp of type float is

(A)*temp
(B)&temp
(C)float& temp

(D)float temp&
Ans: B
59.

What is the output of the following code

char symbol[3]={a,b,c};
for (int index=0; index<3; index++)
cout << symbol [index];
(A)a b c
(B)abc
(C)abc
(D)abc
Ans: C

60.

The process of building new classes from existing one is called ______.

(A)Polymorphism
(B)Structure
(C)Inheritance
(D)Cascading
Ans: C
61.
If a class C is derived from class B, which is derived from class A, all through
public
inheritance, then a class C member function can access
(A)protected and public data only in C and B.
(B)protected and public data only in C.
(C)private data in A and B.

(D)protected data in A and B.


Ans: D
62.
is

If the variable count exceeds 100, a single statement that prints Too many

(A)if (count<100) cout << Too many;


(B)if (count>100) cout >> Too many;
(C)if (count>100) cout << Too many;
(D)None of these.
Ans: C
63.

Usually a pure virtual function

(A)has complete function body.


(B)will never be called.
(C)will be called only to delete an object.
(D)is defined only in derived class.
Ans: D

64.

To perform stream I/O with disk files in C++, youshould

(A)open and close files as in procedural languages.


(B)use classes derived from ios.
(C)use C language library functions to read and write data.
(D)include the IOSTREAM.H header file.
Ans: B
65.

Overloading the function operator

(A)requires a class with an overloaded operator.


(B)requires a class with an overloaded [ ] operator.
(C)allows you to create objects that act syntactically like functions.
(D)usually make use of a constructor that takes arguments.

Ans: A
66.

In C++, the range of signed integer type variable is ________

(A)0 to162
(B)12 to 215 (C) 12 to 277 (D)82 to 0
Ans: B
If 2y,5x==thenyxequals________.(whereis a bitwise XOR operator)
(A)00000111
(B)10000010
(C)10100000
(D)11001000
Ans: A
67.

If an array is declared as

int a[4] = {3, 0, 1, 2}, then values assigned to


a[0] & a[4] will be ________
(A)3, 2
(B)0, 2
(C)3, 0
(D)0, 4
Ans: C
68.

Mechanism of deriving a class from another derived

Class is known as____


(A)Polymorphism
(B)Single Inheritance
(C)Multilevel Inheritance
(D)Message Passing
Ans: C

69.

RunTime Polymorphism is achieved by ______

(A)friend function
(B)virtual function
(C)operator overloading
(D)function overloading
Ans: B
70.
A function call mechanism that passes arguments to a function by passing a
copy of the values of the arguments is __________
(A)call by name
(B)call by value
(C)call by reference
(D)call by value result
Ans: B

71.

In C++, dynamic memory allocation is accomplished

with the operator ____


(A)new
(B)this
(C)malloc( )
(D)delete
Ans: A
72.

If we create a file by ifstream, then the default mode of the file is _________

(A)ios :: out
(B)ios :: in
(C)ios :: app
(D)ios :: binary
Ans: B

73.

A variable defined within a block is visible

(A)from the point of definition onward in the program


.(B)from the point of definition onward in the function
.(C)from the point of definition onward in the block.
(D)throughout the function.
Ans: C
74.

The break statement causes an exit

(A)from the innermost loop only.


(B)only from the innermost switch.
(C)from all loops & switches.
(D)from the innermost loop or switch.
Ans: D
75.

Which of the following cannot be legitimately passed to a function

(A)A constant.
(B)A variable.
(C)A structure.
(D)A header file.
Ans: D
76.

A property which is not true for classes is that they

(A)are removed from memory when not in use.


(B)permit data to be hidden from other classes.
(C)bring together all aspects of an entity in one place.
(D)Can closely model objects in the real world.
Ans: C
77.You can read input that consists of multiple lines

of text using
(A)the normal cout << combination.
(B)the cin.get( ) function with one argument.
(C)the cin.get( ) function with two arguments.
(D)the cin.get( ) function with three arguments.
Ans: C
78.The keyword friend does not appear in
(A)the class allowing access to another class.
(B)the class desiring access to another class.
(C)the private section of a class.
(D)the public section of a class.
Ans: C
79. The process of building new classes from existing
one is called
(A)structure.
(B)Inheritance.
(C)Polymorphism.
(D)Template.
Ans: B
80. If you wanted to sort many large objects or struc
tures, it would be most efficient to
(A)place them in an array & sort the array.
(B)place pointers to them in an array & sort the array
(C)place them in a linked list and sort the linked list.
(D)place references to them in an array and sort the array.
Ans: C

81. Which statement gets affected when i++ is changed to ++i?


(A)i = 20; i++;
(B)for (i = 0; i<20; i++) { }
(C)a = i++;
(D)while (i++ = 20) cout <<i;
Ans: A
82. A friend function to a class, C cannot access
(A)private data members and member functions.
(B)public data members and member functions.
(C)protected data members and member functions.
(D)the data members of the derived class of C.
Ans: D
83. The operator that cannot be overloaded is
(A)++
(B)::
(C)( )
(D)~
Ans: B
84. A struct is the same as a class except that
(A)there are no member functions.
(B)all members are puBlic
(C)cannot be used in inheritance hierarchy.
(D)it does have a this pointer.
Ans: C
85. Pure virtual functions
(A)have to be redefined in the inherited class.

(B)cannot have publicaccess specification.


(C)are mandatory for a virtual class.
(D)None of the above.
Ans: A
86. Additional information sent when an exception is thrown may be placed in
(A)the throw keyword.
(B)the function that caused the error.
(C)the catch block.
(D)an object of the exception class.
Ans: C
87. Use of virtual functions implies
(A)overloading.
(B)overriding.
(C)static binding.
(D)dynamic binding.
Ans: D
88. thispointer
(A)implicitly points to an object.
(B)can be explicitly used in a class.
(C)Can444 be used to return an object.
(D)All of the above.
Ans: D
89. Within aswitch statement
(A)Continue can be used but Break cannot be used
(B)Continue cannot be used but Break can be used
(C)BothContinueand Break can be used

(D)Neither Continue nor Break can be used


Ans:B
90. Data members which arestatic
(A)cannot be assigned a value
(B)can only be used in static functions
(C) cannot be defined in a Union
(D) can be accessed outside the class
Ans:B
91. Which of the following is false for cin?
(A)It represents standard input.
(B)It is an object of istream class.
(C)It is a class of which stream is an object.
(D)Using cin the data can be read from users terminal
.Ans:C
91. It is possible to declare as a friend
(A)a member function
(B)a global function
(C) a class
(D)all of the above
Ans:D
92. In multiple inheritance
(A)the base classes must have only default constructors
(B)cannot have virtual functions
(C)can include virtual classes
(D)None of the above.
Ans:C

93. Declaration of a pointer reserves memory space


(A)for the object.
(B)for the pointer.
(C)both for the object and the pointer.
(D)none of these.
Ans:B
94.for (; ;)
(A)means the test which is done using some expression is always true
(B) is not valid
(C)will loop forever
(D)should be written as for( )
Ans:C
95.The operator << when overloaded in a class
(A) must be a member function
(B)must be a non member function
(C)can be both(A)&(B)above
(D)cannot be overloaded
Ans:C
96. Avirtual class is the same as
(A) an abstract class
(B)a class with a virtual function
(C)a base class
(D)none of the above.
Ans:D
97. Identify the operator that is NOT used with pointers
(A)->

(B)&
(C)*
(D)>>
Ans:D
97. Consider the following statements char *ptr; ptr = hello; cout << *ptr;
What will be printed?
(A)first letter
(B)entire string
(C)it is a syntax error
(D)last letter
Ans:A
98. In which case is it mandatory to provide a destru ctor in a class?
(A)Almost in every class
(B)Class for which two or more than two objects will be created
(C)Class for which copy constructor is defined
(D)Class whose objects will be created dynamically
Ans:D
99. The members of a class, by default, are
(A)public
(B)protected
(C)private
(D)mandatory to specify
Ans:C
100. given a class named Book,
which of the following is not a valid constructor?
(A)Book ( ) { }

(B)Book ( Book b) { }
(C)Book ( Book &b) { }
(D)Book (char* author, char* title) { }
Ans:B

Вам также может понравиться