0% found this document useful (0 votes)
399 views

CS304 Quiz-3 by Vu Topper RM

This document contains a quiz with 40 multiple choice questions about C++ concepts like classes, inheritance, templates, and polymorphism. The questions cover topics like abstract classes, virtual functions, inheritance access levels, class templates, and specialization. The quiz is intended to test the examinee's knowledge of fundamental and advanced C++ programming concepts.

Uploaded by

Yasir Ejaz
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)
399 views

CS304 Quiz-3 by Vu Topper RM

This document contains a quiz with 40 multiple choice questions about C++ concepts like classes, inheritance, templates, and polymorphism. The questions cover topics like abstract classes, virtual functions, inheritance access levels, class templates, and specialization. The quiz is intended to test the examinee's knowledge of fundamental and advanced C++ programming concepts.

Uploaded by

Yasir Ejaz
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/ 28

CS-304 Quiz -3 File

By Vu Topper RM
Question No:1 (Marks:1) Vu-Topper RM
An abstract class is useful when
no classes should be derived from it.
there are multiple paths from one derived class to another.
no objects should be instantiated from its.
you want to defer the declaration of the class.

Question No:2 (Marks:1) Vu-Topper RM


In resolution order compiler search firstly _______.
Select correct option:
Generic Template
Partial Specialization
Complete Specialization
Ordinary function

Question No:3 (Marks:1) Vu-Topper RM


template<> class Vector{ void** p; //.... void*& operator[] ((int i); };
This specialization can then be used as the common implimentation for
all Vectors of pointers.
This spcialization can then be used as the all type implimentation for
one type classes.
This specialization can then be used double type pointers.
This specialization should be used for Vectors of all type int types.

Question No:4 (Marks:1) Vu-Topper RM


In private inheritance derived class pointer can be assigned to base class
pointer in,
Main function

For More Help Contact What’s app 03224021365


In derived class member and friend functions
In base class member and friend functions
None of the these

Question No:5 (Marks:1) Vu-Topper RM


Which statement will be true for concrete class?
it implements an virtual concept.
it can be instantiated
it cannot be instantiated

Question No:6 (Marks:1) Vu-Topper RM


Target of a _____ function call is determined at run time.
instance
virtual
operator
none of given

Question No:7 (Marks:1) Vu-Topper RM


The Specialization pattern after the name says that this specialization is
to be used for every___.
data types
meta types
virtual types
pointers type

Question No:8 (Marks:1) Vu-Topper RM


c++ dynamic binding and polymorphism will be achieved when
member function will be __.
Select correct option:
private
public
virtual

Question No:9 (Marks:1) Vu-Topper RM


Consider the code below, class class1{ protected: void func1(); }; class
class2 : public class1 { }; Function func1 of class1 is ____ in class2,
For More Help Contact What’s app 03224021365
Select correct option:
public
protected
private
none of the given options

Question No:10 (Marks:1) Vu-Topper RM


Consider the code below, class class1{ protected: int i; }; class class2 :
protected class1 { }; Then int member i of class1 is ____ in class2,
Select correct option:
public
protected
private
none of the given options

Question No:11 (Marks:1) Vu-Topper RM


Consider the code below , class class1{ private: void func1(); }; class
class2 : private class1 { }; Function func1 of class1 is ____ in class2,
Select correct option:
public
protected
private
none of the given options
operator
none of given

Question No:12 (Marks:1) Vu-Topper RM


Consider the following statements: 1) int iArray[5]; 2) int *pArr =
iArray;
Select correct option:
These statements will compile successfully
Error in first statement
Error in second statement
None of given options

Question No:13 (Marks:1) Vu-Topper RM


For More Help Contact What’s app 03224021365
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
protected
private
|none of the given options

Question No:14 (Marks:1) Vu-Topper RM


If there is a pointer, p, to objects of a base class, and it contains the
address of an object of a derived class, and both classes contain a virtual
member function, ding(), then the statement p->ding(); will cause the
version of ding() in the ___ class to be executed.
Select correct option:
base
derived
virtual
implemented

Question No:15 (Marks:1) Vu-Topper RM


A class template may inherit from another class template.
Select correct option:
True
False

Question No:16 (Marks:1) Vu-Topper RM


Derived class can inherit from public base class as well as private and
protected base classes
True
False

Question No:17 (Marks:1) Vu-Topper RM


Two functions with same names, parameters and return type can exist
in,
Select correct option:
Function overloading
For More Help Contact What’s app 03224021365
Function overriding
Operator overloading
None of these options

Question No:18 (Marks:1) Vu-Topper RM


An abstract class is useful when
no classes should be derived from it.
there are multiple paths from one derived class to another.
no objects should be instantiated from its.

Question No:19 (Marks:1) Vu-Topper RM


In order to define a class template the first line of definition must be:
template <typename T>
typename <template T>
Template Class <ClassName>
Class <Template T>

Question No:20 (Marks:1) Vu-Topper RM


Select correct line of code for composition relationship between
“Keyboard” class and “Keys” class
class keyboard { Keys type;};
class keys{ KeyBoard type; };
class keyboard : private keys
class keys: private KeyBoard

Question No:21 (Marks:1) Vu-Topper RM


Select correct line of code for inheritance relationship between “Keys”
class and “SpecialKeys” class. “Keys” is parent class while
“SpecialKeys” is child class
class SpecialKeys: public Keys
class Keys: public SpecialKeys
class SpecialKeys:: public Keys
class Keys:: public SpecialKeys

For More Help Contact What’s app 03224021365


Question No:22 (Marks:1) Vu-Topper RM
Methodologies to the development of reusable software relate to
procedural programming
generic programming

Question No:23 (Marks:1) Vu-Topper RM


User can make virtual table explicitly.
True
False

Question No:24 (Marks:1) Vu-Topper RM


A function call is resolved at run-time in___________
non-virtual member function
virtual member function
Both non-virtual member and virtual member function

Question No:25 (Marks:1) Vu-Topper RM


Derived class can inherit from public base class as well as private and
protected base classes
true
false

Question No:26 (Marks:1) Vu-Topper RM


Which of the following function can convert a class into an abstract
class?
bstract function
Concrete function
Virtual function
Pure virtual function

Question No:28 (Marks:1) Vu-Topper RM


A class template may inherit from another class template.
Select correct option:
True
False

For More Help Contact What’s app 03224021365


Question No:29 (Marks:1) Vu-Topper RM
A function call is resolved at run-time in_________
Select correct option:
non-virtual member function
virtual member function
Both non-virtual member and virtual member function.
None of given

Question No:30 (Marks:1) Vu-Topper RM


A class hierarchy
Select correct option:
shows the same relationships as an organization chart.
describes “has a” relationships.
describes “is a kind of” relationships.
shows the same relationships as a family tree.

Question No:31 (Marks:1) Vu-Topper RM


Consider the code below, class class1{ public: int i; }; class class2 :
public class1 { }; Then int member i of class1 is ____ in class2,
Select correct option:
public
protected
private
none of the given options

Question No:32 (Marks:1) Vu-Topper RM


Consider the code below, class c1{ }; class c2 : public c1 { }; class c3 :
public c2 { }; Then c1 is,
Select correct option:
Direct base class of c3
Direct child class of c3
Direct base class of c2
Direct child class of c2

Question No:33 (Marks:1) Vu-Topper RM

For More Help Contact What’s app 03224021365


A class can inherit from more then one class is called.
Select correct option:
Simple inheritance
Multiple inheritances
Single inheritance
Double inheritance

Question No:34 (Marks:1) Vu-Topper RM


Which of the following may inherit form the ordinary
class?
Class template
Partial specialization
Complete specialization
All of given option

Question No:35 (Marks:1) Vu-Topper RM


Which of the following is not type of
inheritance in c++?
Public
Private
Protected
Restricted

Question No:36 (Marks:1) Vu-Topper RM


Which of the following statement is true about partial specialization?
Function templates cannot have partial specialization
Class template cannot have partial specialization
Both class templates and function template can have
partial specialization. d. None of the given
For More Help Contact What’s app 03224021365
Question No:37 (Marks:1) Vu-Topper RM
In resolution order of function template, compiler searches for in the
end
Complete specialization
Partial specialization
Generic template

Question No:38 (Marks:1) Vu-Topper RM


Which of the following is known as Dereference operator in C++? a. +
&

Question No:39 (Marks:1) Vu-Topper RM


When we want to have exactly identical operations on different data
type, are used
Function Template
Function Overloading
Function Overriding

Question No:40 (Marks:1) Vu-Topper RM


When we specialize a function template, it is called
Function overloading
Function overriding
Function template overloading

Question No:41 (Marks:1) Vu-Topper RM


A class template may inherit from another class template.
True
False

Question No:42 (Marks:1) Vu-Topper RM

For More Help Contact What’s app 03224021365


Binding means that target function for a call is selected at
compile time.
Static

Question No:43 (Marks:1) Vu-Topper RM


Which line will produce error. Class phone: private Transmit, private
Receiver { } 1. int main() 2. { 3. phone obj; 4. Tranmit* obj1 = &obj; 5.
Received obj2 = &obj; 6.
5th line will produce error
Question No:44 (Marks:1) Vu-Topper RM
Function overriding is done in context of,
Single class
Derived and base classes

Question No:45 (Marks:1) Vu-Topper RM


Methodologies to the development of reusable software
relate to
Structure programming
generic programming

Question No:46 (Marks:1) Vu-Topper RM


Function template must have a parameter.
True
False

Question No:47 (Marks:1) Vu-Topper RM


The default inheritance mode is,
Public inheritance
Protected inheritance
Private inheritance
For More Help Contact What’s app 03224021365
None of these options

Question No:48 (Marks:1) Vu-Topper RM


Two functions with same names, parameters and return type can exist
in,
Function overloading

Question No:49 (Marks:1) Vu-Topper RM


Consider the code below, class c1{ }; class c2 : public c1 { }; class c3 :
public c2 { }; Then c2 is,
Direct base class of c3
Direct child class of c3

Question No:50 (Marks:1) Vu-Topper RM


It is illegal to make objects of one class members of another class
True
False

Question No:51 (Marks:1) Vu-Topper RM


When we create objects, then space is allocated to:
Member function
Access specifier
Data member
None of given

Question No:52 (Marks:1) Vu-Topper RM


There is only one form of copy constructor.
True
False

For More Help Contact What’s app 03224021365


Question No:53 (Marks:1) Vu-Topper RM
Which of the following features of OOP is used to deal with only
relevant details?
Abstraction
Information hiding
Object

Question No:54 (Marks:1) Vu-Topper RM


___________ Binding means that targets function for a call is selected
at compile time. Static
Dynamic
Automatic
None of given
Class hierarchy

Question No:55 (Marks:1) Vu-Topper RM


Shows the same relationships as an organization chart Describes “has a”
relationships.
Describes “is a kind of” relationships.
Shows the same relationships as a family tree

Question No:56 (Marks:1) Vu-Topper RM


In C++, we declare a function virtual by preceding the function
header with keyword “Inline
True
False

For More Help Contact What’s app 03224021365


Question No:57 (Marks:1) Vu-Topper RM
It is illegal to make objects of one class members of another class.
True
False
Question No:58 (Marks:1) Vu-Topper RM
Derived class can inherit from public base class as well as private and
protected base classes
True
False

Question No:59 (Marks:1) Vu-Topper RM


A function template must have a parameter
True
False

Question No:60 (Marks:1) Vu-Topper RM


Child class can call constructor of its,
Direct base class
Indirect base class
Both direct and indirect base classes
None of these.

Question No:61 (Marks:1) Vu-Topper RM


Which statement will be true for
concrete class?
It implements an virtual concept.
It can be instantiated

Question No:62 (Marks:1) Vu-Topper RM

For More Help Contact What’s app 03224021365


Adding a derived class to a base class requires fundamental changes to
the base class.
True
False

Question No:63 (Marks:1) Vu-Topper RM


A Class or class template can have member ___________ that are
themselves templates. Variable
Function
Objects
None of given

Question No:64 (Marks:1) Vu-Topper RM


Which will be the Primary task or tasks of generic programming?
Categorize the abstractions in a domain into concepts
Implement generic algorithms based on the concepts
Build concrete models of the concepts
All of given

Question No:67 (Marks:1) Vu-Topper RM


By default, assignment operator (=) performs,
Shallow copy
Deep copy
Question No:69 (Marks:1) Vu-Topper RM
In case of dynamic memory allocation in our class we should use
User defined assignment operator

Default assignment operator


copy constructor

Question No:70 (Marks:1) Vu-Topper RM

For More Help Contact What’s app 03224021365


Static casting is,?
Explicit way of calling base class functions from derived class
C++ way of calling base class function from derived class

Question No:71 (Marks:1) Vu-Topper RM


In case of dynamic memory allocation in a class we should use,
User defined default constructor
user defined copy constructor (true)
Question No:72 (Marks:1) Vu-Topper RM
Which of the following types of Inheritance is used to model
“Implemented in terms of” relationship?
Public
private (true)
Question No:73 (Marks:1) Vu-Topper RM
Virtual functions allow you to
create an array of type pointer-to-base class that can hold pointers to
derived classes.
group objects of different classes so they can all be accessed by the
same function code. (true)
Question No:74 (Marks:1) Vu-Topper RM
A class D can be derived from a class C, which is derived from a class
B, which is derived from a class A.
True
False
Question No:75 (Marks:1) Vu-Topper RM
8 Derived class can inherit from public base class as well as private and
protected base classes
For More Help Contact What’s app 03224021365
true
false

Question No:76 (Marks:1) Vu-Topper RM


Which of the following function can convert a class into an abstract
class?
Abstract function
Concrete function
Virtual function
Pure virtual function

Question No77 (Marks:1) Vu-Topper RM


Which of the following causes run time binding?
Declaring object of abstract class
None of the given

Question No:78 (Marks:1) Vu-Topper RM


Identify the correct way of declaring an object of user defined template
class A for char type members?
A obj;
A obj;

Question No:79 (Marks:1) Vu-Topper RM


The user must define the operation of the copy constructor.
True
False

Question No:80 (Marks:1) Vu-Topper RM


Template functions use _________ than ordinary functions.
Greater Memory
Lesser Memory

For More Help Contact What’s app 03224021365


Equal Memory

Question No:81 (Marks:1) Vu-Topper RM


Compiler performs ________ type checking to diagnose type errors,
Static
Dynamic
Bound
Unbound

Question No: 82 (Marks:1) Vu-Topper RM


Which of the following is/are advantage[s] of generic programming?
Reusability
Writability
Maintainability
All of given

Question No:83 (Marks:1) Vu-Topper RM


Vectors contain contiguous elements stored as a[an] ___.
variable
array
function

Question No:84 (Marks:1) Vu-Topper RM


Algorithms can only be implemented using STL containers.
True
False

Question No:85 (Marks:1) Vu-Topper RM


Inheritance is a way to organize
data.
pass arguments to objects of classes.
add features to existing classes without rewriting them.
improve data-hiding and encapsulation.

For More Help Contact What’s app 03224021365


Question No:86 (Marks:1) Vu-Topper RM
We can use "this" pointer in the constructor in the body and even in the
initialization list of any class if we are careful,
True
False

Question No:87 (Marks:1) Vu-Topper RM


Default constructor is such constructor which either has no --------or if
it has some parameters these have -------- values
Parameter, temporary
Null, Parameter
Parameter, default
none of the given

Question No:88 (Marks:1) Vu-Topper RM


The type that is used to declare a reference or pointer is called its ---
default type static type abstract type
reference type

Question No:89 (Marks:1) Vu-Topper RM


Which of these are examples of error handling techniques ?
Abnormal Termination
Graceful Termination Return
the illegal
all of the given

Question No:90 (Marks:1) Vu-Topper RM


Destructor can be overloaded
True
False

Consider the code below.

For More Help Contact What’s app 03224021365


Class class1{ Protected: Int I; }; Class class2: private calls 1{ };
Private
Public
Protected
None of these

Consider the following two lines of code written for a class Student,
Student sobj1; 2. Student sobj2(sobj1)which constructor of student class
will be called?
Default constructor of student class
Copy constructor of student class
Both default and copy constructor of student class
No constructor will be called

___________ binding means that target function for a call is selected at


run time.
Dynamic
A template provides a convenient way to make a family of
functions and classes
classes and exceptions
programs and algorithms
variables and data members

If we have not given any constructor for the class, compiler generates
which of the following constructors?
Implicit Default Constructor

We can call base class assignment operator in derived class user defined
assignment operator,
Using both of these options

In Private Inheritance the public members of base class become


__________ in derived class.
Private
For More Help Contact What’s app 03224021365
In c++ by default access of classes is _________.
Private

We can change behavior of a template using __________.


Template Parameters

We can have ___________ type of member functions in a class.


All

Consider the code below,


class class1{ Private:
Void func1();
};
Class class2 :
public class1{ };
Function func1 of class 1 is in class2.
Private

We can access private members of the class from outside the class using
______ operator with its object pointer.
&

Which of the following is the correct syntax for passing two type
arguments to a template?
template < typename T, typename U>
Suppose Person is a user defined class. In statement “Person * pPtr”,
static type of pPtr is ____________.
Pointer

In Protected Inheritance the public members of base class become


__________ in derived class.
Protected

For More Help Contact What’s app 03224021365


A parent class can call constructor of its child class through,
Can not call the constructor of its child class

Which of the following can be passed as type arguments to templates?


Both Primitive types and User-defined types

A Child class can call constructor of its parent class through,


Its constructor initialization list

Sender of the message does not need to know the exact class of receiver
in________.
Polymorphism

In c++, compiler can generate which of the following operators’ code,


==

Which of the following is TRUE,


Derived class pointer can be used as Base class pointer

A template argument is preceded by the keyword ________.


Class

Public Inheritance represents,


“IS A” relationship

Friend Functions of a class are _________ members of that class.


None of the these

A class with no pure virtual function is a ________ class.


Concrete

To make a pure virtual, we need to give______ after ( ) of this function.


=0

For More Help Contact What’s app 03224021365


If the user does not specify the type of inheritance then the default type
of inheritance is ____________.
Private inheritance

Which of the following is NOT casting operator in C++ standard?


var_cast

In case of public inheritance, protected members of base class will be


_____________ in derived class?
Protected

Which of the following access specifier ensures that base class member
is accessible in derived class of this base class and NOT outside of this
class?
Protected

In case of protected inheritance, public members of base class will be


_____________ in derived class?
Protected

Polymorphism always works with ___________.


constant objects

Which of the following is the correct code to instantiate the object of


given template vector class of int type?
Template< class T >
Class vector {
};
Vector obj ;<int>;
Vector<int> obj;
Vector obj<>int;
Vector int obj;

Which of the following represents complete specialization?


Template < int, char >
Template < class T, float>
For More Help Contact What’s app 03224021365
Template< class , class W>
Template <class T. class U.int>

Which of the following is known as Dereference operator in C++?


+
*
&
::

Which of the following is the correct syntax for passing two type
argument to a template?
template < type T, type U>
template < typename T, typename U>
template <type T.type U>
template Typename < T,U >

which will be the primary task or task of genric programming ?


categorize the abstractions in a domain into concepts
all of given
build concrete models of the concept
implement genric algorithms based on the concept

Which of the following can be passed as type argument to template?


Primitive type
User defined types `
Both primitive type and user defined types
None of the given options

Which of the following statement is true about partial specialization?


Function templates cannot have partial specialization
Class template cannot have partial specialization
Both class templates and function template can have partial
specialization.
None of the given

For More Help Contact What’s app 03224021365


The parameters given in temple definition other than those used for
mentioning templates types are called
Type Parameters
Non Type parameters
Default Type Parameters
None of the given option

In case of template specialization, if compiler cannot find required


complete specialization then it searches for some
General template
Complete template
Partial specialization
None of the given

Which of the following is the correct way to define a template class X?


Class < typename T>class X{}
Template class C{}
Template < typename T> classX{}
Typename class X{}

The Parameters given in tamplate definition other than those used for
mentioning tamplates type are called ________.
Default type parameters
None of the given option
Non-type parameter
Type parameter

may inherit from a complete specialization


Partial specialization
Complete specialization
Ordinary class
All of given options

In statement “template<class t.classU.intI=5> ”. then non-type


parameters is _______.
Class T
For More Help Contact What’s app 03224021365
Class U
int I
All of the given option

in resolution order compiler search first ______.


Complete specialization
Ordinary function
Partial specialization
Generic template

_______class is a single class that provides functionality to operate on


different type of data?
Friend
Template
Ordinary
None of the give options

Methodologies to the development of reusable software relate to ____.


Structure programming
Procedural programming
Generic programming
None of the given

A template argument is preceded by the keyword ________. `


vector
class
template
type*

Each _of a template class by default becomes function template .


Date member
Member function
Type parameter
Object

For More Help Contact What’s app 03224021365


In resolution order, highest priority is given to_____ in template
specialization.
General template
Complete specialization
Partial specialization
None of the given options

In order to define a class template, the first line of definition must be:
Template <type nameT >
typename <template T>
Template Class <class name >
Class<template t>

Which of the following may inherit form the ordinary class?


Class template `
Partial specialization
Complete specialization
All of given option

In c++ generic programming is done using


Procedures
Packages
Templates
None of the given

Which of the following represents partial specialization?


Template < int, char >
Template < class T, Type t>
Template<classT,classu,int>
Template< typename T, class W>

To make a pure virtual, we need to give _after() of this function.


=0;
=1;
Null;
None of the given
For More Help Contact What’s app 03224021365
A class template _____.
Facilitates reuse of class
Dose not facilitates reuse of class
Does not support generic methods
Does not support static members

We can change behavior of template using ______.


Template parameters
Function parameters
Class Templates
none of the given options

A template provides a convenient way to make a family of


variables and data members
functions and classes
classes and exceptions
programs and algorithms

When we specialize a function template, it is called _____.


Function overloading
Function overriding
Function template overloading
Function template overriding

We can change behavior of template using _______.


Template parameters
Function parameters
Class Templates
none of the given options

it is good practice to avoid ____ objects to treat polymorphically.


Protected
Array
Public
Private
For More Help Contact What’s app 03224021365
Which of the following represents complete specialization ?
Template <class class W>
Template <class T. float >
Template <int.char>
Template <class t.classU.int>

______may inherit from a complete specialization .


Ordinary class
Partial specialization
All of the given option
Complete specialization

For More Help Contact What’s app 03224021365

You might also like