VU Quiz 3

CS304 Quiz No 3 2024

Q1: Which of the following operators must be overloaded as a member function?

a. Inequality Operator (!=)

b. Equality Operator (==)

c. Stream Extraction Operator (>>)

d. Function Operator (())

Q2: If class A is derived from class B and class C, and class B is derived from class D, which of the following statements is correct?

a. Class A contains all the characteristics of class B.

b. Class A contains all the characteristics of class D.

c. Class C contains all the characteristics of class A.

d. None of these

Q3: In the following code, what will be the access specifier of function func1() within the scope of class2?

C++

class class1 {
protected:
  void func1();
};

class class2 : public class1 {
  // ...
};

a. private

b. protected

c. public

Q4: If you do not define a copy constructor for a derived class, which constructor will the compiler use to initialize the base class part?

a. Implicit Parameterized Constructor

b. Explicit Default Constructor

c. Explicit Parameterized Constructor

d. Implicit Default Constructor

Q5: In the following code, what is the relationship between c2 and c1?

C++

class c1 { /* ... */ };
class c2 : public c1 { /* ... */ };
class c3 : public c2 { /* ... */ };

a. Base class of c1

b. Indirect child class of c1

c. Sibling class of c1

d. Direct child class of c1

Q6: What will be the output of the following code?

C++

int oldValue = 10;
int newValue = ++oldValue;

a. oldValue=10, newValue=10

b. oldValue=10, newValue=11

c. oldValue=11, newValue=10

d. oldValue=11, newValue=11

Q7: In the following code, what will be the access specifier of the member variable i within the scope of class2?

C++

class class1 {
protected:
  int i;
};

class class2 : protected class1 {
  // ...
};

a. private

b. protected

c. public

Q8: If you do not define any constructor for a class, what type of constructor does the compiler generate?

a. Implicit Parameterized Constructor

b. Implicit Default Constructor

c. Explicit Default Constructor

d. Explicit Parameterized Constructor

Q9: In the following code, what is the relationship between Parent2 and Child2?

C++

class GrandParent { /* ... */ };
class Parent1 : public GrandParent { /* ... */ };
class Parent2 : public GrandParent { /* ... */ };
class Child1 : public Parent1 { /* ... */ };
class Child2 : public Parent1 { /* ... */ };

a. Child2 is the base class of Parent2.

b. Child2 is the derived class of Parent2.

c. Child2 is the sibling class of Parent2.

d. None of these

Leave a Reply

Your email address will not be published. Required fields are marked *