cs304 Quiz 2 2021
cs304 Quiz 2 2021
Template
Template <int.char>
The parameters given in template definition other than those used for mentoring templates
types are called
Non-type parameters
Vector
In resolution order of function template compiler searches for ___________in the end.
Generic template
Member function
Int |
Complete template
Partial specialization
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
Class U
Class.
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
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,
In case of private inheritance, private members of base class will be ________ in derived
class.
hidden
Operator Precedence
Which of the following is the correct syntax of declaring static variable "count" of type int?
Inline function
int main()
return 0;
11
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
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
Private inheritance
In Protected Inheritance the public members of base class become ________ in derived
class.
Protected
Ordinary function
generic programming
Packages
class class1{
private:
void func1();
};
};
private
public:
int i;
};
public
class class1{
protected:
int i;
};
protected
Restriction
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.
More than 3
Eat
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
Multiple Inheritance
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.
<<
Objects
Class A
In C++, which of the following operator can only be overloaded as a member function of
the class?
Stream Extraction Operator: >>
Left to Right
c1*c2
Suppose for a class String, assignment operator is overloaded with following declaration.
"Vehicle class is base class. Bus, Car, and Truck are derived classes"
Vehicle
Unary Operators
Subtyping means that derived class is behaviorally ________ with the base class.
Compatible
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?
receiver
Suppose there is an object of type Person, which of the following can be considered as one
of its attributes?
Name
explicit
Choose correct declaration of overloaded stream insertion operator for class String as non-
member friend function.
Which of the following classes are used by Amphibious vehicle to inherit characteristics?