Sample Question Paper in C++
Sample Question Paper in C++
interface IStaff
{
interface IStaff
private void
{
display(){
A private void display(); C
// statement1
}
}
}
A current C this
B self D auto
A Table C Flower
B ATM machine D Chameleon
A Framework C Generics
B Pattern D Class
Examples Pattern
(a) Multiple small (1)
boxes within a Decorator
1 larger box
(b) Pizza with olives (2)
Facade
and Jalapeno
(c) Debit card and (3)
Composite
cheque book
(d) Receptionist in a (4)
Proxy
hotel
class Tree{
private string pName; // line1
public void setPName(string pName)
{
2 pName = pName; // line2
}
static void Main()
{
Tree p1 = new Tree(); // line3
p1.setPName("Apple"); // line4
}
}
A line1 C line3
B line2 D line4
a) Generic class that introduces a type variable named ‘T’ which can be
used as a type anywhere inside the class.
4
b) A generic function is a method that does not have a specific type
attached to the parameters or even the return type.
c) Generics does not allow overloading of template functions with
parameters of unspecified types.
d) The most common use of generics is the creation of typed Collections
such as List, Stack, and Array.
A a, b, c C a, b, d
B a, c D c, d
1 Identify the two different ways to interpret the process of overriding. (multiple
options)
A Subclass C Refinement
B Replacement D Subtype
A Project B C Project A
B Runtime error D Compile time error
A auto C friend
B extern D static
A local C public
B global D private
Which of the following statements represents the output of the following code
snippet?
a = 2;
switch (a)
{
case 1 : {
cout<< “First Statement”;
4
}
case 2 : {
cout<< “Second Statement”;
}
default : {
cout<< “ Bye”;
break;
}
}
1 Queue:: Queue(void)
{
front = rear = NULL;
};
The constructor function for this The constructor function for this
A class initializes the pointers for the C class deletes the pointers for the
one end of the queue two ends of the queue
The constructor function for
B this class initializes the pointers D None of these
for the two ends of the queue
Description Term
Initializes variables when the object is
(A) (1) Destructor.
2 created.
Frees the memory space when the object is
(B) (2) Containers.
terminated.
(C) Classes defined within a class. (3) Access specifier.
Determines how the members of the base
(D) (4) Constructor.
class are inherited by the child class.
#include <iostream>
3 int main() { float x=1.5;
double y=1.5;
if (x == 1.5f)
cout << “Equal “ ;
else
cout << “Not equal “;
return 0; }
Which of the following statements about pure virtual functions are false?
4 a. The body of the pure virtual function is defined in the base class.
b. Objects of the classes containing pure virtual functions can be created.
c. Constructors can be defined as virtual function.
d. The body of the pure virtual function is not defined in the parent class.
A c, d C b, d
B a, c, d D a, b, c