0% found this document useful (0 votes)
240 views11 pages

cs304 Quiz 2 2021

CS304 quiz 2, 2022 covered topics related to templates, inheritance, polymorphism and operator overloading in C++. The quiz contained multiple choice questions to test understanding of concepts like template parameters, inheritance access specifiers, virtual functions, overloaded operators and more. Template classes, vectors and the standard template library were some key areas assessed.

Uploaded by

Zeeshan Malik
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)
240 views11 pages

cs304 Quiz 2 2021

CS304 quiz 2, 2022 covered topics related to templates, inheritance, polymorphism and operator overloading in C++. The quiz contained multiple choice questions to test understanding of concepts like template parameters, inheritance access specifiers, virtual functions, overloaded operators and more. Template classes, vectors and the standard template library were some key areas assessed.

Uploaded by

Zeeshan Malik
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/ 11

CS304 quiz 2, 2022

______________ Class is a single class provides functionally to operate on different type of


data.

Template

Which of the following may inherit from an ordinary class?

All of the given

Which of the following represents complete specialization?

Template <int.char>

The parameters given in template definition other than those used for mentoring templates
types are called

Non-type parameters

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

typename &lt;class T &gt; class X {};

Which of the following is a sequence Container?

Vector

In resolution order of function template compiler searches for ___________in the end.

Generic template

__________ may inherit from a complete specialization.

All of the given option

Which of the following may inherit from an ordinary class?

All of the given option

Which of the following is NOT an Associate Container?


Group

When was specialize a function template .it is called___________

Function template overriding

Which of the following is/are key component(s) of standard Template Library?

All of the given option

Each ____________ of a template class by default becomes function template.

Member function

In statement “template<class U,int |=5>”the non type parameter is

Int |

Solution order highest priority is given to ________ in template

Complete template

In case of template specialization ,if compiler cannot find required complete

Partial specialization

_________ is a pointer which is declared outside the _________

Cursor, Container

Suppose a template class “Test” has a static data member. How many copies of this static
data member following line of C++ code?

Three

In statement template <class T,class U ,int |=5> the non-parameter is ______.

Class U

A template argument is preceded by the keyword ____________.

Class.

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


All of the given

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

var_cast

Which of the following types of Inheritance is used to model "Implemented in terms of"
relationship?

Private

In case of protected inheritance, public members of base class will be ________ in derived
class?

protected

In C++ by default access of classes is ________.

Private

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.

derived

Suppose we have defined derived class copy constructor but have not defined base class
copy constructor then compiler will,

Use base class default constructor

In case of private inheritance, private members of base class will be ________ in derived
class.

hidden

________ defines the order of evaluation of an operator in an expression.

Operator Precedence

Which of the following is the correct syntax of declaring static variable "count" of type int?

static int count;


Defining a function in class body, the compiler treats that function as:

Inline function

What is the output of the following code?

int main()

int const x = 10;

cout << ++x;

return 0;

11

Which of the following statements best describes the Constructor?

Constructor is used to initialize the data members of a class.

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?
Junk value, 5, Junk value

Which of the following is a strong relationship?

Inheritance

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

Static

In case of public inheritance, protected members of base class will be ________ in derived
class.

Protected

A template provides a convenient way to make a family of

functions and classes

Function overriding is done in context of,

Derived and base class

Which of the following is TRUE.

Derived class pointer can be used as Base class pointer

The default inheritance mode is,

Private inheritance

In Protected Inheritance the public members of base class become ________ in derived
class.

Protected

In resolution order compiler search firstly ________.

Ordinary function

Compiler generated copy constructor performs ________.

Both Shallow and Deep copy


A pure virtual function is a virtual function that

causes its class to be abstract

Methodologies to the development of reusable software relate to ________.

generic programming

In C++ generic programming is done using ________.

Packages

Consider the code below,

class class1{

private:

void func1();

};

class class2 : private class1 {

};

Function func1 of class1 is ________ in class2.

private

When derived class has user defined assignment operator.

Compiler itself calls base class default constructor.

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

Both from its constructor initialization list or body

Consider the code below,


class class1{

public:

int i;

};

class class2 : public class1 {

};Then int member i of class1 is ________ in class2.

public

Consider the code below,

class class1{

protected:

int i;

};

class class2 : private class1 {

};Then int member i of class1 is ________ in class2.

protected

Static casting is,

Implicit way of calling base class functions from derived class

How many objects of a given class may be constructed in an application?

As many as the application asks for

The other name of specialization is ________.

Restriction

How can we differentiate between constructors and destructors?


Destructors are preceded with a tilde (~) symbol, and constructors are not preceded with
any symbol.

How many entities are there in the following scenario?Ali lives in the house that is near the
tree and he also drives his car.

Which of the following is True about Destructor?

All of the given

How many objects are involved in the N-ary association?

More than 3

Which of the following can be the behavior of an object "Usman"?

Eat

In C++, Composition is a relationship between ________ and ________ objects.

Parent, child

If you have three classes in a C++ program A, B, and C where class A inherits from class B,
then class ________ contains all the characteristics of class ________.

A, B

In case when we define the function outside the class then we must use the keyword
________ to make the function inline.

inline

Mermaid is an example of:

Multiple Inheritance

Assignment operators are:


Right associative

Generalization is ________ approach.

Top-bottom

The ________ tells the compiler what task the function will be performing.

Function declaration

uppose str1, str2 and str3 are objects of class String. Choose appropriate declaration of
overloaded assignment operator for the following statement to work correctly.

String& operator =(const String &);

In operator overloading, which of the following operator takes one or no argument.

<<

Class is blueprint of ________.

Objects

Polymorphism makes the system:

All of the given

If class B inherits from class A then it contains all characteristics of ________.

Class A

What is meant by multiple inheritance?

Deriving a derived class from more than one base class

In C++, which of the following operator can only be overloaded as a member function of
the class?
Stream Extraction Operator: >>

Insertion operator is ________ associative.

Left to Right

In expression c1*c2+c3-c4 which of the following will be executed in first order?

c1*c2

Suppose for a class String, assignment operator is overloaded with following declaration.

void operator =(const String &);

What will happen when we will write following statement in main()?

str1 = str2 = str3;

Where, str1, str2 and str3 are objects of class String.

Compiler will generate compile time error.

Identify the abstract class from the given statement:

"Vehicle class is base class. Bus, Car, and Truck are derived classes"

Vehicle

Which of the following operators operate on one operand?

Unary Operators

Subtyping means that derived class is behaviorally ________ with the base class.

Compatible

In ________, Base class can't always be replaced by the derived class.

Specialization

The overloaded '-' operator for Complex class will be called with reference to ________ in
the following statement
Complex C3 = C1 - C2;

Complex

What is a class?

A class is a description of a kind of object

In polymorphism, messages can be interpreted in different ways depending upon the


________ class.

receiver

Suppose there is an object of type Person, which of the following can be considered as one
of its attributes?

Name

Which of the following is True about class?

All of the given

In C++, which of the following keywords works only with constructors?

explicit

Choose correct declaration of overloaded stream insertion operator for class String as non-
member friend function.

friend ostream & operator << ();

Which of the following classes are used by Amphibious vehicle to inherit characteristics?

Both Land & Water Vehicle

You might also like