0% found this document useful (0 votes)
44 views14 pages

Sample Question Paper in C++

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
44 views14 pages

Sample Question Paper in C++

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 14

Object-Oriented Programming Concepts and C++

Simple Questions (5)

Select the correct answer (single option):


1
Identify the correct syntax for declaring an interface named IStaff.

interface IStaff
{
interface IStaff
private void
{
display(){
A private void display(); C
// statement1
}
}
}

protected interface IStaff interface IStaff


{ {
B void display(); D void display();
} }

Fill in the blank:


2 The ______________ keyword is used in C++, C#, and Java for a
pseudo-variable.

A current C this
B self D auto

3 Select the correct answer (single option):


Which of the following objects is an example of abstraction?

A Table C Flower
B ATM machine D Chameleon

© Aptech Ltd. Project Private Page 1 of 6


Object-Oriented Programming Concepts and C++

Fill in the blank:

4 A ________ is a set of reusable software components or classes that form


the basis of an application.

A Framework C Generics
B Pattern D Class

Select the correct answer (single option):


5
Which of the following options is not a correct example of method
overloading?

void add(int a, int


void add(int a, int b) b)
{} {}
A C
int add(int a, int b) void add(float a, int
{} b)
{}
void add(int a, int
void add(int a, int b) b)
{} {}
B D
void add(float a, float b) void add(int a, float
{} b)
{}

© Aptech Ltd. Project Private Page 2 of 6


Object-Oriented Programming Concepts and C++

Average Questions (5)

Match the columns:

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

A A-3, B-1, C-4, D-2 C A-1, B-3, C-4, D-2


B A-1, B-2, C-3, D-4 D A-4, B-1, C-2, D-3

Select the correct answer (single option):

Identify the incorrect statement in the following C# code.

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

© Aptech Ltd. Project Private Page 3 of 6


Object-Oriented Programming Concepts and C++

Select the correct answer (multiple options):


3
Which of the following problems can arise when a class Z inherits two classes X
and Y that in turn inherit a class called W?

A Locality problem C Reference problem


B Diamond problem D Pointer problem

Select the correct answer (single option):

Which of the following statements about Generics are true?

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

Select the correct answer (single option):


5
Which of the following options represents a decorator pattern?

A Shopkeeper in a shop C Product manufacturing factory


B Icecream with choco chips D ATM of a bank

© Aptech Ltd. Project Private Page 4 of 6


Object-Oriented Programming Concepts and C++

Difficult Questions (3)

1 Identify the two different ways to interpret the process of overriding. (multiple
options)

A Subclass C Refinement
B Replacement D Subtype

Select the correct answers (single options):

Consider the following C# code:


class Tutor
{
public virtual void showTask()
{
Console.WriteLine("Task A" );
}
}
class PartTimeTutor : Tutor{
2 public override void showTask()
{
Console.WriteLine("Task B" );
}
}
static void Main()
{
PartTimeTutor e1 = new PartTimeTutor();
e1.showTask();
}
What will be the output of the code?

A Project B C Project A
B Runtime error D Compile time error

© Aptech Ltd. Project Private Page 5 of 6


Object-Oriented Programming Concepts and C++

Match the columns:

Description Software Concept


(a) The degree to which the components (1)
Class
know about each other.
(b) A set of steps or instructions, or a (2)
Coupling
3 procedure to accomplish something.
(c) The specific characteristics of an (3)
object are masked and only the
Method
common features of the category to
which the object belongs are exposed.
(d) A structure that defines and encloses (4)
the characteristics and behavior Generalization
pertaining to a particular entity.

A A-2, B-3, C-4, D-1 C A-1, B-3, C-4, D-2


B A-3, B-1, C-4, D-2 D A-4, B-1, C-2, D-3

© Aptech Ltd. Project Private Page 6 of 6


Sample QBank for
Object-Oriented Programming With C++
Object-Oriented Programming Concepts and C++

Simple Questions (5]

Select the correct answer (single option):


1
Identify the correct description of a class.

A class is a group of objects


A that have some properties, C Class is a data structure.
common behavior, and common
relationship.
When a class is defined,
Class defines an instance of
B D the entity comes into
objects.
existence.

Select the correct answers (multiple options):


2
Which of the following are not advantages of using function overloading?

Different function names can be It makes maintenance of


A C
used for the same operation. code easier.
It makes reading of code
B It makes debugging difficult. D
difficult.

Fill in the blanks:

3 The keyword _____________________ is not repeated in the function


definition after it has been used once in the declaration.

A auto C friend
B extern D static

Fill in the blanks:


4 _____________ means that the address of the code in a member function
invocation is determined at the last possible moment.

A Inheritance C Dynamic binding


B Overloading D Polymorphism

© Aptech Ltd. Project Private Page 1 of 7


Object-Oriented Programming Concepts and C++

Fill in the blanks:


5
A stack is a structure, which works on the ____________ principle.

A FIFO C Round Robin method


B LIFO D All of these

© Aptech Ltd. Project Private Page 2 of 7


Object-Oriented Programming Concepts and C++

Average Questions (5)

Match the columns:

Description Escape Sequence


(A) Backspace (1) \f
1
(B) Form feed (2) \a
(C) Bell (3) \x
(D) Hexadecimal number display (4) \b

A (A)-(4), (B)-(1), (C)-(2), (D)–(3) C (A)-(2), (B)-(1), (C)-(4), (D)–(3)


B (A)-(1), (B)-(3), (C)-(2), (D)–(4) D (A)-(3), (B)-(1), (C)-(2), (D)–(4)

Select the correct answers (multiple options):


2
Which of these are the basic categories of the scope of variables?

A local C public
B global D private

Select the correct answers (multiple options):


3
Which of the following statements are true for Linked lists?

Access of individual members is done


A Linked lists are created using arrays. C sequentially beginning from the head of
the list.
Linked lists use dynamic memory Individual members in a linked list can be
B D
allocation. accessed using an index.

© Aptech Ltd. Project Private Page 3 of 7


Object-Oriented Programming Concepts and C++

Select the correct answer (single option):

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;
}
}

A Second Statement C Second Statement Bye


First Statement Second
B Second Statement Bye D
Statement Bye

Select the correct answer (single option):


5
Which one of the following is invoked to free the memory storage automatically?

A Base class C Constructor


B A derived class D Destructor

© Aptech Ltd. Project Private Page 4 of 7


Object-Oriented Programming Concepts and C++

Difficult Questions (5)

Select the correct answer (single option):

Identify the purpose of the given lines of code.

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

Match the columns:

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.

A (A)-(4), (B)-(1), (C)-(2), (D)–(3) C (A)-(1), (B)-(3), (C)-(2), (D)–(4)


B (A)-(2), (B)-(4), (C)-(1), (D)–(3) D (A)-(3), (B)-(2), (C)-(1), (D)–(4)

© Aptech Ltd. Project Private Page 5 of 7


Object-Oriented Programming Concepts and C++

Select the correct answer (single option):

Identify the output for the given program.

#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; }

A Compile time error C Runtime error


B Equal D Not equal

Select the correct answer (single option):

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

© Aptech Ltd. Project Private Page 6 of 7


Object-Oriented Programming Concepts and C++

Match the columns:

Description Pointer statement

5 (A) Address of variable code. (1) int *ptr;


(B) Pointer to a character variable (2) &code
(C) Pointer to an integer variable. (3) float *ptr;
(D) Pointer to floating point variable. (4) char *ptr;

A (A)-4, (B)-1, (C)-2, (D)–3 C (A)-3, (B)-1, (C)-2, (D)–4


B (A)-2, (B)-4, (C)-1, (D)–3 D (A)-1, (B)-4, (C)-2, (D)–3

© Aptech Ltd. Project Private Page 7 of 7

You might also like