100% found this document useful (2 votes)
5K views26 pages

CS304 - Current Final Term Paper Solved

This document contains a final term examination for an Object Oriented Programming course. It consists of 24 multiple choice questions testing concepts like polymorphism, inheritance, templates, containers, and constructors. The exam covers key topics in object oriented design and the C++ Standard Template Library.

Uploaded by

Muhammad Shahbaz
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
100% found this document useful (2 votes)
5K views26 pages

CS304 - Current Final Term Paper Solved

This document contains a final term examination for an Object Oriented Programming course. It consists of 24 multiple choice questions testing concepts like polymorphism, inheritance, templates, containers, and constructors. The exam covers key topics in object oriented design and the C++ Standard Template Library.

Uploaded by

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

1|Page

FINALTERM EXAMINATION
CS304- Object Oriented Programming (Session - It is sometimes useful to specify a class from which
1) no objects will ever be created.
3 ► True
Question No: 1 ( Marks: 1 ) - Please choose ► False
one
Question No: 6 ( Marks: 1 ) - Please choose
Which one of the following terms must relate to one
polymorphism?
Assume a class Derv that is privately derived from
► Static allocation class Base. An object of class Derv located in main()
can access
► Static typing
► public members of Derv.
► Dynamic binding
► protected members of Derv.
► Dynamic allocation
► private members of Derv.
► protected members of Base.
Question No: 2 ( Marks: 1 ) - Please choose
one
Question No: 7 ( Marks: 1 ) - Please choose
one
Multiple inheritance can be of type
► Public
A pointer to a base class can point to objects of a
► Private
derived class.
► Protected
► All of the given
► True
► False
Question No: 3 ( Marks: 1 ) - Please choose
Question No: 8 ( Marks: 1 ) - Please choose
one
one
When a subclass specifies an alternative definition
A copy constructor is invoked when
for an attribute or method of its superclass, it is
► a function do not returns by value.
_______ the definition in the superclass.
► an argument is passed by value.
► overload
► a function returns by reference.
► overriding
► an argument is passed by reference.
► copy riding
► none of given
Question No: 9 ( Marks: 1 ) - Please
choose one
Question No: 4 ( Marks: 1 ) - Please choose
one
A function call is resolved at run-time
in___________
Like template functions, a class template may not
► non-virtual member function.
handle all the types successfully.
► virtual member function.
► True
► Both non-virtual member and virtual
► False
member function.
► None of given
Question No: 5 ( Marks: 1 ) - Please choose
one
Question No: 10 ( Marks: 1 ) - Please
choose one
2|Page

► There are multiple paths from one


When the base class and the derived class have a derived class to another.
member function with the same name, you must be ► We do not want to instantiate its object.
more specific which function you want to call ► You want to defer the declaration of the
(using ___________). class.
► scope resolution operator
► dot operator Question No: 15 ( Marks: 1 ) - Please
► null operator choose one
► Operator overloading
Which of the following is incorrect line regarding
function template?
► template<class T>
► template <typename U>
Question No: 11 ( Marks: 1 ) - Please ► Class<template T>
choose one ► template < class T, class U>

Each try block can have ______ no. of catch blocks. Question No: 16 ( Marks: 1 ) - Please
choose one
►1
►2 Which of the following is/are advantage[s] of
►3 generic programming?
► As many as necessary. ► Reusability
► Writability
► Maintainability
Question No: 12 ( Marks: 1 ) - Please ► All of given
choose one
Question No: 17 ( Marks: 1 ) - Please
Two important STL associative containers are choose one
_______ and _______.
► set,map By default the vector data items are initialized to
► sequence,mapping ____
► setmet,multipule
► sit,mat ►0
► 0.0
Question No: 13 ( Marks: 1 ) - Please ►1
choose one ► null

The mechanism of selecting function at run time Question No: 18 ( Marks: 1 ) - Please
according to the nature of calling object is called, choose one

► late binding Which one of the following functions returns the


► static binding total number of elements in a vector.
► virtual binding ► length();
► None of the given options ► size();
► ele();
Question No: 14 ( Marks: 1 ) - Please ► veclen();
choose one
Question No: 19 ( Marks: 1 ) - Please
An abstract class is useful when, choose one
► We do not derive any class from it.
3|Page

Suppose you create an uninitialized vector as


follows: Question No: 23 ( Marks: 1 ) - Please
choose one
vector<int> evec;
After adding the statment, When is a constructor called?
evec.push_back(21); ► Each time the constructor identifier is
what will happen? used in a program statement
► The following statement will add an element ► During the instantiation of a new
to the start (the back) of evec and will initialize it object
with the value 21. ► During the construction of a new class
► The following statement will add an element ► At the beginning of any program
to the center of evec and will reinitialize it with the execution
value 21.
► The following statement will delete an Question No: 24 ( Marks: 1 ) - Please
element to the end (the back) of evec and will choose one
reinitialize it with the value 21.
► The following statement will add an Consider the code below,
element to the end (the back) of evec and class Fred {
initialize it with the value 21. public:
Question No: 20 ( Marks: 1 ) - Please Fred();
choose one ...
};
An STL container can not be used to, int main()
► hold objects of class employee. {
► store elements in a way that makes them Fred a[10];
quickly accessible. Fred* p = new Fred[10];
► compile c++ programs. ...
► organize the way objects are stored in }
memory Select the best option,
► Fred a[10]; calls the default constructor
Question No: 21 ( Marks: 1 ) - Please 09 times
choose one Fred* p = new Fred[10]; calls the default
constructor 10 times
Algorithms can only be implemented using STL
containers. ► Produce an error

► Fred a[10]; calls the default constructor


► True 11 times
► False Fred* p = new Fred[10]; calls the default
constructor 11 times
Question No: 22 ( Marks: 1 ) - Please
choose one ► Fred a[10]; calls the default constructor
10 times
The main function of scope resolution operator Fred* p = new Fred[10]; calls the default
(::) is, constructor 10 times
► To define an object
► To define a data member
► To link the definition of an identifier to its Question No: 25 ( Marks: 1 ) - Please
declaration choose one
► To make a class private
4|Page

► non of the given


Associativity can be changed in operator
overloading. Question No: 30 ( Marks: 1 ) - Please
► True choose one
► False
Public methods of base class can --------- be
accessed in its derived class
Question No: 26 ( Marks: 1 ) - Please
► directly
choose one
► inderectly
► simultaniously
A normal C++ operator that acts in special
► non of the given
ways on newly defined data types is said to be
► glorified.
► encapsulated.
► classified.
► overloaded.
Question No: 3 ( Marks: 1 ) - Please
choose one
Question No: 27 ( Marks: 1 ) - Please
What is true about function templates?
choose one

Which operator can not be overloaded?


► The compiler generates only one copy
► The relation operator ( >= )
of the function template
► Assignment operator ( = )
► The compiler generates a copy of
► Script operator ( [] )
function respective to each type of data
► Conditional operator (? : )
► The compiler can only generate copy
for the int type data
► None of the given.
Question No: 28 ( Marks: 1 ) - Please
choose one Question No: 5 ( Marks: 1 ) - Please
choose one
Suppose obj1 and obj2 are two objects of a user
defined class A. An + operator is overloaded to add
template <>
obj1 and obj2 using the function call obj1+obj2.
class Vector<char*> { }
Identify the correct function prototype against the
given call?
This is an example of partial specialization.
► A operator + ( A &obj);
► True
► int + operator();
► False
► int operator (plus) ();
► A operator(A &obj3);
Question No: 7 ( Marks: 1 ) - Please
choose one
Question No: 29 ( Marks: 1 ) - Please
choose one
A non-virtual member function is defined in a
Default constructor is such constructor which either base class and overridden in a derived class; if
has no ---------or if it has some parameters these that function is called through a base-class
have -------- values pointer to a derived class object, the derived-
► Parameter, temporary class version is used.
► Null, Parameter
► Parameter, default ► True
5|Page

► False Which is not the Advantage of inheritance?


► providing class growth through natural
Question No: 10 ( Marks: 1 ) - Please selection.
choose one ► facilitating class libraries.
► avoiding the rewriting of code.
If there is a pointer p to objects of a base class, ► providing a useful conceptual
and it contains the address of an object of a framework.
derived class, and both classes contain a
nonvirtual member function, ding(), then the
statement p->ding(); will cause the version of Question No: 17 ( Marks: 1 ) - Please
ding() in the _____ class to be executed. choose one
► Base
► Derived class DocElement
► Abstract {
► virtual public:
virtual void Print() { cout << "Generic
element"; }
Question No: 14 ( Marks: 1 ) - Please };
choose one class Heading : public DocElement
{
If you define a vector v with the default public:
constructor, and define another vector w with a void Print() { cout << "Heading element"; }
one-argument constructor to a size of 11, and };
insert 3 elements into each of these vectors class Paragraph : public DocElement
with push_back(), then the size() member {
function will return ______ for v and _____ for public:
w. void Print() { cout << "Paragraph
element"; }
};
► 11 for v and 3 for w. void main()
{
DocElement * p = new Paragraph();
► 0 for v and 0 for w.
p->Print();
► 0 for v and 3 for w.
}
► 3 for v and 11 for w.
When you run this program, it will print out a
Question No: 15 ( Marks: 1 ) - Please
single line to the console output.
choose one
What will be in that line?
Which of the following may not be an integral
part of an object?
Select one correct answer from the following
► State
list:
► Behavior
► Protected data members
► All of given ► Generic element

Question No: 16 ( Marks: 1 ) - Please


choose one ► Heading element
6|Page

► Paragraph element Consider a class named Vehicle, which of the


following can be the instance of class Vehicle?
1. Car
► Nothing will be printed. 2. Computer
3. Desk
Question No: 18 ( Marks: 1 ) - Please 4. Ahmed
choose one 5. Bicycle
6. Truck
When a virtual function is called by referencing
a specific object by name and using the dot ► 1, 4, 5
member selection operator (e.g.,
squareObject.draw()), the reference is resolved ► 2, 5, 6
at compile time.
► 1, 2, 3, 6
► True
► 1, 5, 6
► False

Question No: 19 ( Marks: 1 ) - Please


Question No: 25 ( Marks: 1 ) - Please
choose one
choose one
In case of multiple inheritance a derived class
Consider the code below,
inherits,
class Fred {
► Only the public member functions of its
public:
base classes
Fred();
► Only the public data members of its
...
base classes
};
► Both public data members and member
int main()
functions of all its base classes
{
► Data members and member functions
Fred a[10];
of any two base classes
Fred* p = new Fred[10];
...
Question No: 20 ( Marks: 1 ) - Please
}
choose one
Select the best option,
► Fred a[10]; calls the default constructor
When we write a class template the first line
09 times
must be:
Fred* p = new Fred[10]; calls the default
► template < class class_name>
constructor 10 times
► template < class data_type>
► template < class T >
► Produce an error
Here T can be replaced with any name but it is
preferable.
► Fred a[10]; calls the default constructor
► class class-name()
11 times
class template<class_name>
Fred* p = new Fred[10]; calls the default
constructor 11 times
Question No: 24 ( Marks: 1 ) - Please
► Fred a[10]; calls the default constructor
choose one
10 times
7|Page

Fred* p = new Fred[10]; calls the default


constructor 10 times
Class is not a mechanism to create
Question No: 26 ( Marks: 1 ) - Please
objects and define user data types.
choose one 1. true
When a variable is define as static in a class 2. false
then all object of this class,
► Have different copies of this variable
► Have same copy of this variable
► Can not access this variable Memory is allocated to non static
► None of given members only, when:
Question No: 27 ( Marks: 1 ) - Please 1. Class is created
choose one
2. Object is defined
The life of sub object is dependant on the life of 3. Object is initialized
master class in _____________.
► Separation 4. Object is created
► Composition
► Aggregation
► None of the given

Question No: 28 ( Marks: 1 ) - Please Unary operators and assignment operator


choose one
are right associative.
___________, which means if A declares B as 1. true
its friend it does NOT mean that A can access
private data of B. It only means that B can 2. false
access all data of A.
► Friendship is one way only
► Friendship is two way only
► NO Friendship between classes The >= operator can't be overloaded.
► Any kind of friendship
1. true
Question No: 29 ( Marks: 1 ) - Please 2. false
choose one

Which of the following operators always takes


no argument if overloaded? If we are create array of objects through
new operator, then
1. We can call overloaded constructor
through new
►/ 2. We can’t call overloaded
►- constructor through new
►+
► ++
8|Page

3. We can call default constructor 3. giving new meanings to existing Class


through new members.

4. None of the given 4. making new C++ operators

Question No: 1 ( Marks: 1 ) - Please choose


one
__________ Operator will take only one Which of the following causes run time binding?
operand.
1. New ► Declaring object of abstract class
► Declaring pointer of abstract class
2. int ► Declaring overridden methods as non-virtual
► None of the given
3. object
Question No: 2 ( Marks: 1 ) - Please choose
4. none of the given one
Which of the following is the best approach if it is
required to have more than one functions having
Which of the following operator(s) take(s) exactly same functionality and implemented on
one or no argument if overloaded? different data types?

1. ++ ► Templates
► Overloading
2. * ► Data hiding
► Encapsulation
3. %
Question No: 6 ( Marks: 1 ) - Please choose
4. All of the given choices one

this pointer does not pass implicitly to A class template may inherit from another class
template.
__________ functions.
1. Static Member ► True
► False
2. Non-Static Member
Question No: 8 ( Marks: 1 ) - Please choose
3. Instance Number one
In Private -------------- only member functions and
4. None of the given friend classes or functions of a derived class can
convert pointer or reference of derived object to
that of parent object
Operator overloading is
► specialization
► inheritance
1. making C++ operators work with ► abstraction
objects. ► composition

2. giving C++ operators more than they


can handle.
Question No: 10 ( Marks: 1 ) - Please
9|Page

choose one ► Template Class <ClassName>


Template functions use _________ than ► Class <Template T>
ordinary functions. Question No: 30 ( Marks: 1 )
In case of multiple inheritance a derived class
► Greater Memory inherits,
► Lesser Memory ► Only the public member functions of its base
► Equal Memory classes
► None of the given options ► Only the public data members of its base
classes
Question No: 11 ( Marks: 1 ) - Please ► Both public data members and member
choose one functions of all its base classes
Non Template Friend functions of a class are ► Data members and member functions of
friends of ________instance/s of that class. any two base classes

► All
► One specific Question No: 3 ( Marks: 1 ) - Please choose
► All instances of one date type one
► None of the given options

A function template can not be overloaded by


another function template.
Question No: 14 ( Marks: 1 ) - Please ► True
choose one
A template argument is preceded by the keyword ► False
________.
► vector Question No: 5 ( Marks: 1 ) - Please choose
► class one
► template
► type* Identify the correct way of declaring an object of
user defined template class A for char type
members?
Question No: 27 ( Marks: 1 ) ► A< char > obj;
Describe the way to declare a template class
as a friend of any class. ► <char>A obj;

► A obj<char>; wrong
Question No: 28 ( Marks: 1 )
Classes like TwoDimensionalShape and ► Obj <char> A;
ThreeDimensionalShape would normally be
concrete, while classes like Sphere and Cube Question No: 6 ( Marks: 1 ) - Please choose
would normally be abstract. one
► True
► False The user must define the operation of the copy
constructor.
Question No: 29 ( Marks: 1 )
In order to define a class template, the first line ► True
of definition must be:
► False
► template <typename T>
► typename <template T>
10 | P a g e

► variable

► array

► function

► datatype

Question No: 8 ( Marks: 1 ) - Please choose


one

The find() algorithm Question No: 13 ( Marks: 1 ) - Please choose


one
► finds matching sequences of elements in two
containers.
In a de-queue, (chose the best option)
► finds a container that matches a specified
container. ► data can be quickly inserted or deleted at
any arbitrary location.
► takes iterators as its first two arguments.
► data can be inserted or deleted at any
► takes container elements as its first two arbitrary location, but the process is relatively slow.
arguments.
► data can not be quickly inserted or deleted at
Question No: 9 ( Marks: 1 ) - Please choose either end.
one
► data can be inserted or deleted at either end,
Compiler performs ________ type checking to but the process is relatively slow.
diagnose type errors,

► Static pg261
Question No: 15 ( Marks: 1 ) - Please choose
► Dynamic one

► Bound What is a class?


► Unbound
► A class is a section of computer memory
containing objects.

Question No: 11 ( Marks: 1 ) - Please choose ► A class is a section of the hard disk reserved
one for object oriented programs

► A class is the part of an object that contains


Vectors contain contiguous elements stored as a[an] the variables.
___.
► A class is a description of a kind of object.
11 | P a g e

► private,public

► static,public

► none of given

Question No: 21 ( Marks: 1 ) - Please choose


one

Question No: 16 ( Marks: 1 ) - Please choose The type that is used to declare a reference or pointer is
one called its ---------

► default type
Inheritance is a way to
► static type

► organize data. ► abstract type

► pass arguments to objects of classes. ► reference type

► add features to existing classes without


rewriting them.
Question No: 22 ( Marks: 1 ) - Please choose
► improve data-hiding and encapsulation. one

Question No: 17 ( Marks: 1 ) - Please choose


one ------------- members are somewhere between public and
private members. They are used in inheritance

We can use "this" pointer in the constructor in the ► protected


body and even in the initialization list of any class if
we are careful, ► public

► True ► private

► False ► global

Question No: 18 ( Marks: 1 ) - Please choose Question No: 23 ( Marks: 1 ) - Please choose
one one

________ and ______ methods may not be Which of these are examples of error handling
declared abstract. techniques ?

► Abnormal Termination
► private,static
► Graceful Termination
12 | P a g e

► Return the illegal ► True

► all of the given ► False

Question No: 27 ( Marks: 2 )

Describe the way to declare a template function as a


friend of any class.
Question No: 24 ( Marks: 1 ) - Please choose
one Template templatename
Class calssname
{
----------------- follow try block to catch the object Friend void friend templatename (classname
thrown <templatename> astric const prt classname);
}
► catch block

► throw block
Question No: 28 ( Marks: 2 )
► main block

► non of the given State any two reasons why the virtual methods can
not be static?
Question No: 25 ( Marks: 1 ) - Please choose
one 1-virtual method can not be static as it is dynamic
2-as virtual method is dynamic so it works
automatically that is also another reason
Graphical representation of the classes and objects That virtual method can not be static.
is called object model it shows -------

► Class Name only Question No: 29 ( Marks: 2 )

► Class Name and attributes


Explain the statement below,
► Relationships of the objects and classes
vector<int> ivec(4, 3);
► all of the given

Question No: 26 ( Marks: 1 ) - Please choose


one Question No: 30 ( Marks: 2 )

Destructor can be overloaded Explain two benefits of setter functions.


13 | P a g e

1- It minimize the changes to move the objects


in inconsistent states Question No: 33 ( Marks: 3 )
2- You can write checks in your setter
functions to check the validity of data
entered by the user, for example age Give the c++ code of case sensitive comparison
functions to check to calculate the age from function of string class.
date entered.

Question No: 31 ( Marks: 3 ) Question No: 34 ( Marks: 5 )

Consider the code below, What is random_iterator? What is relation between


random_iterator and Vector?
template< typename T >
class T1 { Random_iterator: it provided both increment and
public: decrement and also provide constant time methods
T i; for moving forward and backword in arbitrary sized
protected: steps. Ramdom iterator provide asentially all of the
T j; operations of ordinary c pointer arithmetic.
private:
T k; Vector class provide an stl style random access
friend void Test(); iterator for use with generic algorithm since neither
}; the vactor nor the matrix classes are container
classes in actuall. The iterator class is really an
This code has a template class T1 with three iterator of data object that is viewed by vector or
members i,j and k and a friend function Test(), you matrix.
have to describe which member/s of T1 will be
available in function Test().

public: Question No: 35 ( Marks: 5 )


T i;
protected:
T j; What would be the output of this code?

class mother {
public:
Question No: 32 ( Marks: 3 ) mother ()
{ cout << "mother: no parameters\n"; }
mother (int a)
What do you mean by Stack unwinding? { cout << "mother: int parameter\n"; }
};
When we want to check what happens actually to
the local variables in the try block when then an class daughter : public mother {
exception is thrown this concept is called stack public:
unwinding. daughter (int a)
{ cout << "daughter: int parameter\n\n"; }
};
14 | P a g e

operator function's declaration is appropriate


class son : public mother { for the given call? Rational_number_1 + 2.325
public: Where Rational_number_1 is an object of user
son (int a) : mother (a) defined class Rational_number.
{ cout << "son: int parameter\n\n"; } Rational_number operator+( Rational_number
}; & obj);
None of the given choices
int main () { Rational_number operator+(Rational_number
&obj, double& num);
daughter rabia (0);
operator+(double& obj);
son salman(0);

return 0;
9. Sub-Object can not be initialized using the
} constructor
True
Output will be False

Mother 10. Let Suppose a class Student with objects


Daughter: rabia std1, std2, and std3. For the statement std3 =
Son: salman std1 - std2 to work correctly, if the
overloaded - operator must
take two arguments.
None of the given choices
CS304 Object Oriented Programming 2. take single argument
In______________, a pointer or reference to an take three arguments
object is created inside a class.
Aggregation 11. Copy constructor is called when:
Composition An object is created in term of pre existence
Inheritance object
Association An object is created
An object is initialized
CS304 Object Oriented Programming None of the given

5. Select correct line of code for inheritance 12. Which of the following operator doesn't
relationship between “Keys” class and take any argument if overloaded?
“SpecialKeys” class. “Person” is parent class /
while “SpecialKeys” is child class. -
class SpecialKeys: public Keys +
class Keys: public SpecialKeys None of the given choices
class SpecialKeys:: public Keys
class Keys:: public SpecialKeys 13. “A fan has wings”. Which type of
relationship exists between fan and wings?
6. “Keyboard” class is composed of “keys” Aggregation
class. What will be the order of execution of Association
constructor of “Keyboard” class and “Keys” Composition
class? Inheritance
First Detructor::Keys..
Second Destructor::Keyboard.. 14. What type of relationship exists between
First Destructor:: Keyboard.. “Account” class and “SavingAccount” class?
Second Destructor:: Keys.. Inheritance
Composition
7. Identify which of the following overloaded Aggregation
15 | P a g e

Association objects are always executed before the


constructors of the master class.
15. Select correct line of code for Select correct option:
inheritance relationship between Aggregation
“Nationality” class and “Citizen” class. Composition
Inheritance
“Nationality” is parent class while “Citizen” is
Association
child class.
class Citizen: public Nationality
class Nationality: public Citizen Which line will produce error. Class phone:
class Citizen:: public Nationality private Transmit, private Receiver { } 1. int
class Nationality:: public Citizen main() 2. { 3. phone obj; 4. Tranmit* obj1 =
&obj; 5. Received obj2 = &obj; 6. }
16.To initialize an array of objects, only Select correct option:
_____________ will be called 3rd line will produce error
Defualt Constructor 4th line will produce error
Overloaded Constructor 3rd and 4th line will produce error.
5th line will produce error
Default Object
None of the above

In C++ generic programming is done using

Procedures
Packages 5 Methodologies to the development of reusable
Templates software relate to__________.
None of given
A Structure programming
Templates automatically create different versions B procedural programming
of a function, depending on user input.
Select correct option: C generic programming
True D None of the given
False

Derived class can inherit from public base class


as well as private and protected base classes 6 User can make virtual table explicitly.
True
False
A True
_____ is creating objects of one class inside B false
another class.
Association
Composition 9 Which of the following function can convert a
Aggregation class into an abstract class?
Inheritance

In ______________destructor of sub-object is A Abstract function


called after destructor of master class.
smilechat: options B Concrete function
Aggregation C Virtual function
Composition
Inheritance D Pure virtual function
Association
10 Target of a _______ function call is
determined at run time.
A instance
In ______________constructors of the sub-
16 | P a g e

B virtual private function


C operator inline function
None of the given
D none of given

Person" class is composed off "Nationality"


Select correct line of code for inheritance
class. What will be the order of execution
relationship between "Person" class and
of constructor of "Keyboard" class and
"Supervisor" class. "Person" is parent
"Keys" class
class while "Supervisor" is child class.
First Constructor:: Nationality..
Select correct option:
Second Constructor:: Person..
class Supervisor: public Person
First Constructor:: Person..
class Person: public Supervisor
Second Constructor:: Nationality..
class Supervisor:: public Person
class Person:: public Supervisor
The direction specifies which object
contains the other object. In composition
contains the other object. In aggregation
direction is must
Yes
Select correct line of code for inheritance
No
relationship between "Keys" class and
"SpecialKeys" class. "Person" is parent
Select correct line of code for inheritance
class while "SpecialKeys" is child class.
relationship between "Account" class and
Select correct option:
"SavingAccount" class. "Account" is parent
class SpecialKeys: public Keys
class while "SavingAccount" is child clas
class Keys: public SpecialKeys
class SpecialKeys:: public Keys
class SavingAccount : public Account
class Keys:: public SpecialKeys
class Account: public SavingAccount
class SavingAccount :: public Account
class Account :: public SavingAccount
Select correct line of code for inheritance
relationship between "Nationality" class
and "Citizen" class. "Nationality" is parent Select correct line of code for inheritance
relationship between "Keys" class and
class while "Citizen" is child class.
class Citizen: public Nationality "StandardKeys" class. "Person" is parent
class while "StandardKeys" is child class.
class Nationality: public Citizen
class Citizen:: public Nationality
class Nationality:: public Citizen class StandardKeys: public Keys
class Keys: public StandardKeys
class StandardKeys:: public Keys
class Keys:: public StandardKeys
What will be most appropriate C++ data
Object can be declared constant with the
use of Constant keyword. type for variable "InterestRate
Int
Select correct option:
True long int
double
False
float

Always make pointer to null, whenever Select correct line of code for composition
relationship between "Keyboard" class and
dynamic memory is deleted.
Select correct option: "Keys" class
True
False class keyboard { Keys type;};
class keys{ KeyBoard type; };
__________ provide the facility to access
the data member. class keyboard : private keys
class keys: private KeyBoard
Select correct option:
accesser function
17 | P a g e

Method "getInterestRate()" should double


belongs to class Person" class is composed off "Nationality"
Account() class. What will be the order of execution
SavingAccount() of constructor of "Keyboard" class and
CurrentAccount() "Keys" class
None of the given options First Constructor:: Nationality..
Second Constructor:: Person..
The sub-object's life is not dependant on First Constructor:: Person..
the life of master class in ___________. Second Constructor:: Nationality..
Composition
Aggregation
Seperation
non of the given
A template provides a convenient way to
correct line of code for inheritance make a family of
relationship between "Nationality" class Select correct option:
and "Foreigner" class. "Nationality" is variables and data members
parent class while functions and classes
"Foreigner" is child class. classes and exceptions
class Foreigner: public Nationality programs and algorithms
class Nationality: public Foreigner
class Foreigner:: public Nationality
A class hierarchy
Select correct option:
shows the same relationships as an
correct line of code for inheritance organization chart.
relationship between "Gender" class describes "has a" relationships.
and "Female" class. "Gender" is parent describes "is a kind of" relationships.
class while "Female" is child shows the same relationships as a family
tree.
class.
class Female: public Gender Sender of the message does not need to
class Gender: public Female know the exact class of receiver
in______.
class Female:: public Gender Select correct option:
class Gender:: public Female Abstraction
Polymorphism
Account" is parent class while Inheritance
"CurrentAccount" is child class. Can I none of the given
inherit the destructor of "account" class?
Yes
Adding a derived class to a base class
no requires fundamental changes to the base
Select correct line of code for aggregation class.
relationship between "Person" class and Select correct option:
"Address" class. True
class Person { Address * a; }; False
class Address { Person * a; };
class Person { Address a; };
class Address { Person a; }; Binding means that target function for a
call is selected at compile time.
What will be most appropriate C++ data Select correct option:
type for variable "MinimumBalance"? Static
Select correct option: Dynamic
int Automatic
long int None of given
float
18 | P a g e

Consider the code below, class c1{ };


class c2 : public c1 { }; class c3 : public
c2 { }; Then c2 is,
Select correct option:
Function overriding is done in context of,
Select correct option: Direct base class of c3
Single class Direct child class of c3
Single derived class Direct base class of c1
Single base class None of these
Derived and base classes

Consider the code below,


class class1{
public: void func1();
}; Virtual functions allow you to
class class2 : protected class1 { Select correct option:
}; create an array of type pointer-to-base
Function func1 of class1 is ____ in class that can hold pointers to derived
class2, classes.
Select correct option: create functions that can never be
public accessed.
protected group objects of different classes so
private they can all be accessed by the same
none of the given options function code.
use the same function call to execute
the following statements: 1) int iArray[5]; member functions of objects from
2) int *pArr = iArray; different classes.
Select correct option:
These statements will compile
successfully
Error in first statement Consider the following statements: 1) int
Error in second statement iArray[5]; 2) int *pArr = iArray;
None of given options Select correct option:
These statements will compile
successfully
Error in first statement
function template must have a Error in second statement
parameter. None of given options
Select correct option:
True
False
In type in depended function template
The default inheritance mode is, should be use where code and behavior
Select correct option: must be identical.
Public inheritance Select correct option:
Protected inheritance True
Private inheritance False
None of these options
Consider the code below, class
Two functions with same names, class1{ protected: int i; }; class class2 :
parameters and return type can exist in, private class1 { }; Then int member i of
Select correct option: class1 is ____ in class2,
Function overloading Select correct option:
Function overriding
Operator overloading public
None of these options protected
private
19 | P a g e

none of the given options In base class member and friend


functions
In specialization we can, None of the given options
Select correct option:
Replace child class with its base class Which statement will be true for concrete
Replace base class with its child class class?
(Not Sure) it implements an virtual concept.
Replace both child and base classes it can be instantiated
interchangeably it cannot be instantiated
None of the given options none of given

Consider the code below, class


class1{ public: void func1(); }; class The Specialization pattern after the name
class2 : public class1 { }; Function func1 says that this specialization is to be used
of class1 is ____ in class2, for every___.
Select correct option: Select correct option:
public data types
protected meta types
private virtual types
none of the given options pointers type

It is illegal to make objects of one class c++ dynamic binding and polymorphism
members of another class. will be achieved when member function
Select correct option: will be __.
True Select correct option:
False private
public
In resolution order compiler search virtual
firstly _______. inline
Select correct option:
Generic Template Consider the code below, class
Partial Specialization class1{ protected: void func1(); }; class
Complete Specialization class2 : public class1 { }; Function func1
Ordinary function of class1 is ____ in class2,
Select correct option:
template<> class Vector{ void** p; //.... public
void*& operator[] ((int i); }; protected
Select correct option: private
This specialization can then be used as the none of the given options
common implimentation for all Vectors of
pointers. Consider the code below, class
This spcialization can then be used as the class1{ private: void func1(); }; class
all type implimentation for one type class2 : private class1 { }; Function func1
classes. of class1 is ____ in class2,
This specialization can then be used Select correct option:
double type pointers. public
This specialization should be used for protected
Vectors of all type int types. private
none of the given options

In private inheritance derived class


pointer can be assigned to base class Consider the following statements: 1) int
pointer in, iArray[5]; 2) int *pArr = iArray;
Select correct option: Select correct option:
Main function These statements will compile
In derived class member and friend successfully
functions Error in first statement
20 | P a g e

Error in second statement


None of given options

Consider the code below, class


class1{ private: int i; }; class class2 :
private class1 { }; Then int member i of
class1 is ____ in class2,
Select correct option:
public template<> class Vector{ void** p; //....
protected void*& operator[] ((int i); };
private Select correct option:
none of the given options
This specialization can then be used as the
If there is a pointer, p, to objects of a common implimentation for all Vectors of
base class, and it contains the address of pointers.
an object of a derived class, and both This spcialization can then be used as the
classes contain a virtual member function, all type implimentation for one type
ding(), then the statement p->ding(); will classes.
cause the version of ding() in This specialization can then be used
the ___ class to be executed. double type pointers.
Select correct option: This specialization should be used for
base Vectors of all type int types.
derived
virtual Consider the code below, class
implemented class1{ public: int i; }; class class2 :
protected class1 { }; Then int member i of
class1 is ____ in class2,
Select correct option:
Consider the code below, class public
class1{ public: int i; }; class class2 : protected
public class1 { }; Then int member i of private
class1 is ____ in class2, none of the given options
Select correct option:
public Consider the code below, class
protected class1{ private: void func1(); }; class
private class2 : public class1 { }; Function func1
none of the given options of class1 is ____ in class2,
Select correct option:
Consider the code below, class c1{ }; public
class c2 : public c1 { }; class c3 : public protected
c2 { }; Then c1 is, private
Select correct option: none of the given options
Direct base class of c3
Direct child class of c3
Direct base class of c2
Direct child class of c2 When we create objects, then space is
allocated to:
A class can inherit from more then one Member function
class is called. Access specifier
Select correct option: Data member
Simple inheritance None of given
Multiple inheritances
Single inheritance There is only one form of copy
Double inheritance constructor.
True
False
21 | P a g e

Objects
Which of the following features of OOP is None of given
used to deal with only relevant details?
Abstraction Which will be the Primary task or tasks of
Information hiding generic programming?
Object Categorize the abstractions in a domain
into concepts
Implement generic algorithms based on
____________ Binding means that the concepts
targets function for a call is selected at Build concrete models of the concepts
compile time. All of given
Static
Dynamic ] __________class to be executed.
Automatic Base
None of given Derived
Virtual
Implemented

In C++, we declare a function virtual by A class template ____________


preceding the function header with Facilitates reuse of class
keyword "Inline" Does not facilitate reuse of class
True
False

It is illegal to make objects of one class Select correct line of code for inheritance
members of another class. relationship between "Person" class and
True "Supervisor" class. "Person" is parent
False class while "Supervisor" is child class.
Select correct option:
\
class Supervisor: public Person
Friends are used exactly the same for class Person: public Supervisor
template and non-template classes. class Supervisor:: public Person
True
False class Person:: public Supervisor

Select correct line of code for inheritance


Child class can call constructor of its, relationship between "Keys" class and
Direct base class "SpecialKeys" class. "Person" is parent
Indirect base class class while "SpecialKeys" is child class.
Both direct and indirect base classes Select correct option:
None of these.
class SpecialKeys: public Keys
class Keys: public SpecialKeys
A class D can be derived from a class C,
class SpecialKeys:: public Keys
which is derived froma class B, which is
derived from a class A class Keys:: public SpecialKeys
True
False

A Class or class template can have


member ___________ that are
themselves templates.

Variable
Function
22 | P a g e

What will be most appropriate C++ data


type for variable "InterestRate
Int
long int
double
float
Select correct line of code for inheritance
relationship between "Nationality" class
and "Citizen" class. "Nationality" is parent
class while "Citizen" is child class.
Copy constructor is called when:
class Citizen: public Nationality
class Nationality: public Citizen Select correct option:

class Citizen:: public Nationality


class Nationality:: public Citizen
on August 19, 2014 at 2:10pm
There is an object of type Person, which of
the following can be considered as one of
its attributes:
Name
Workat()
Person" class is composed off "Nationality"
Age
class. What will be the order of execution
of constructor of "Keyboard" class and Both age and name
"Keys" class
Select correct line of code for inheritance
First Constructor:: Nationality..
relationship between "Nationality" class
Second Constructor:: Person..
and "Citizen" class. "Nationality" is parent
First Constructor:: Person..
class while "Citizen" is child class.
Second Constructor:: Nationality..
class Citizen: public Nationality
class Nationality: public Citizen
class Citizen:: public Nationality
What will be most appropriate C++ data class Nationality:: public Citizen
type for variable "MinimumBalance"?
Select correct option:
int Consider the code below, class
long int
class1{ public: void func1(); }; class
class2 : protected class1 { }; Function
float
double func1 of class1 is ____ in class2,
public
protected
Person" class is composed off "Nationality"
class. What will be the order of execution private
of constructor of "Keyboard" class and none of the given options
"Keys" class
First Constructor:: Nationality.. The following statements: 1) int
Second Constructor:: Person.. iArray[5]; 2) int *pArr = iArray;
First Constructor:: Person.. These statements will compile
Second Constructor:: Nationality..
successfully
Error in first statement
Error in second statement
23 | P a g e

None of given options


Consider the code below, class c1{ }; Consider the following statements: 1)
class c2 : public c1 { }; class c3 : int iArray[5]; 2) int *pArr = iArray;
public c2 { }; Then c2 is, These statements will compile
Direct base class of c3 successfully
Direct child class of c3 Error in first statement
Direct base class of c1 Error in second statement
None of these None of given options

Consider the following statements: 1)


int iArray[5]; 2) int *pArr = iArray; Consider the code below, class
These statements will compile class1{ public: int i; }; class class2 :
successfully public class1 { }; Then int member i of
Error in first statement class1 is ____ in class2,
Error in second statement public
None of given options protected
Consider the code below, class private
class1{ public: void func1(); }; class none of the given options
class2 : public class1 { }; Function Consider the code below, class c1{ };
func1 of class1 is ____ in class2, class c2 : public c1 { }; class c3 :
public public c2 { }; Then c1 is,
protected Direct base class of c3
private Direct child class of c3
none of the given options Direct base class of c2
It is illegal to make objects of one Direct child class of c2
class members of another class. A class can inherit from more then
True one class is called.
False Simple inheritance
template<> class Vector{ void** p; //.... Multiple inheritances
void*& operator[] ((int i); }; Single inheritance
This specialization can then be used Double inheritance
as the common implementation for all template<> class Vector{ void** p; //....
Vectors of pointers. void*& operator[] ((int i); };
This specialization can then be used This specialization can then be used
as the all type implementation for one as the common implimentation for all
type classes. Vectors of pointers.
This specialization can then be used This spcialization can then be used as
double type pointers. the all type implimentation for one
This specialization should be used for type classes.
Vectors of all type int types. This specialization can then be used
double type pointers.
This specialization should be used for
24 | P a g e

Vectors of all type int types.


Consider the code below, class In C++, we declare a function virtual
class1{ public: int i; }; class class2 : by preceding the function header with
protected class1 { }; Then int member keyword “Inline”.
i of class1 is ____ in class2, True
public False
protected It is illegal to make objects of one
private class members of another class.
none of the given options True
Consider the code below, class False
class1{ private: void func1(); }; class
class2 : public class1 { }; Function
func1 of class1 is ____ in class2,
public
Friends are used exactly the same for
protected
template and non-template classes.
private
True
none of the given options
False
When we create objects, then space
is allocated to:
Child class can call constructor of its,
Member function
Direct base class
Access specifier
Indirect base class
Data member
Both direct and indirect base classes
None of given
None of these.
There is only one form of copy
constructor.
True A class D can be derived from a class
False C, which is derived froma class B,
Which of the following features of which is derived from a class A
OOP is used to deal with only relevant True
details? False
Abstraction
Information hiding
Object
___________ Binding means that targets A Class or class template can have
function for a call is selected at member ___________ that are
compile time. themselves templates.
Static Variable
Dynamic Function
Automatic Objects
None of given None of given
25 | P a g e

Both from its constructor initialization


list or body
Which will be the Primary task or Can not call the constructor of its
tasks of generic programming? child class
Question # 7 of 10 ( Start time:
Categorize the abstractions in a 05 :56 :07 PM ) Total Marks: 1
domain into concepts A template provides a convenient way
Implement generic algorithms based to make a family of
Select correct option :
on the concepts
variables and data members
Build concrete models of the functions and classes
concepts classes and exceptions
All of given programs and algorithms
Question # 8 of 10 ( Start time:
05 :57 :18 PM ) Total Marks: 1
Consider the code below , class
] class1 { private : int i ; }; class class2 :
protected class 1 { }; Then int member i
of class 1 is
Question # 1 of 10 ( Start time: ______ in class 2 ,
05 :19 :33 PM ) Total Marks: 1 Select correct option :
Consider the code below , class public
class1 { private : int i ; }; class class2 : protected
private class1 { }; Then int member i private
of class 1 is none of the given options
______ in class 2 , Question # 9 of 10 ( Start time:
Select correct option : 05 :58 :38 PM ) Total Marks: 1
public __________ Binding means that target
protected function for a call is selected at
private compile time.
none of the given options Select correct option :
Static
Question # 4 of 10 ( Start time: Dynamic
05 :52 :59 PM ) Total Marks: 1 Automatic
A class D can be derived from a class None of given
C, which is derived from a class B ,
which is derived from a class A . Question # 1 of 10 ( Start time:
Select correct option : 02 :40 :05 PM ) Total Marks : 1
True If we are create array of objects
False through new operator, then
Question # 5 of 10 ( Start time: Select correct option :
05 :53 :40 PM ) Total Marks: 1 We can call overloaded constructor
In c + + dynamic binding and through new
polymorphism will be achieved when We can ’ t call overloaded constructor
member function will be ____ . through new
Select correct option : We can call default constructor
private through new
public None of the given
virtual
inline Question # 3 of 10 ( Start time:
Question # 6 of 10 ( Start time: 02 :41 :59 PM ) Total Marks : 1
05 :54 :03 PM ) Total Marks: 1 Constant data members can be
A parent class can call constructor of initialized by using :
its child class through , Select correct option :
Select correct option : Constant Member Function
Its constructor initialization list Non- constant Member Function
Its constructor body
26 | P a g e

Member Initializer List


Class
Question # 4 of 10 ( Start time:

Question # 5 of 10 ( Start time:


02 :44 :36 PM ) Total Marks : 1
Consider the call given below of an
overloaded operator " + " ,
Rational _ number _ 1 +
Rational _ number _ 2 Where
Rational _ number _ 1 and
Rational _ number _ 2 are the two objects
of Rational _ number class (a user
defined class ). Identify which of the
above two objects
will be passed as an argument to the
overloaded operator function ?
Select correct option :
Rational _ number _ 1
None of the given choices
Both Rational _ number _ 1 &
Rational _ number _ 2
any of the two objects , randomly
Question # 6 of 10 ( Start time:
02 :46 :07 PM ) Total Marks : 1
Associativity can change due to
operator overloading.
Select correct option :
True
False
Question # 7 of 10 ( Start time:
02 :47 :02 PM ) Total Marks : 1
Consider the following code segment :
class test { int a ; int b ; int c; public:
test() :b (5 ) ,c( a ),a ( b ) {} } What will the
value of
variables a , b , and c after instantiating
an object of above class ?
Select correct option :
5,5,5
5 , Junk value , 5
Junk value , 5 , Junk value
Junk value , 5 , 5
Question # 8 of 10 ( Start time:
02 :48 :31 PM ) Total Marks : 1
Operator overloading is
Select correct option :
making C + + operators work with
objects .
giving C + + operators more than they
can handle.
giving new meanings to existing
Class members .
making new C + + operators.
Question # 10 of 10 ( Start time :
02 :49 :43 PM ) Total Marks : 1

You might also like