CS304P Quiz 8 fall 2024

0

 

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

    1. Public
    2. Private
    3. Protected
    4. All of the given
  2. Which of the following is NOT casting operator in C++ standard?

    1. static_cast
    2. var_cast
    3. dynamic_cast
    4. reinterpret_cast
  3. Which of the following types of Inheritance is used to model "Implemented in terms of" relationship?

    1. Public
    2. Private
    3. Protected
    4. Confidential
  4. In case of protected inheritance, public members of base class will be ________ in derived class?

    1. private
    2. public
    3. protected
    4. hidden
  5. In C++ by default access of classes is ________.

    1. Private
    2. Protected
    3. Public
    4. None of the given
  6. 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.

    1. base
    2. derived
    3. virtual
    4. implemented
  7. Suppose we have defined derived class copy constructor but have not defined base class copy constructor then compiler will,

    1. Use base class default constructor
    2. Generate base class copy constructor itself
    3. Use base class assignment operator
    4. None of the given
  8. In case of private inheritance, private members of base class will be ________ in derived class.

    1. private
    2. public
    3. protected
    4. hidden
  9. A template argument is preceded by the keyword ________.

    1. vector
    2. class
    3. template
    4. type*
  10. ________ Binding means that target function for a call is selected at compile time.

    1. Static
    2. Dynamic
    3. Automatic
    4. None of the given
  11. In case of public inheritance, protected members of base class will be ________ in derived class.

    1. private
    2. public
    3. Protected
    4. hidden
  12. A template provides a convenient way to make a family of

    1. variables and data members
    2. functions and classes
    3. classes and exceptions
    4. programs and algorithms
  13. Function overriding is done in context of,

    1. Single class
    2. Single derived class
    3. Single base class
    4. Derived and base class
  14. Which of the following is TRUE.

    1. Derived class pointer can be used as Base class pointer
    2. Base class pointer can be used as Derived class pointer
    3. Both of these options
    4. None of the given
  15. The default inheritance mode is,

    1. Public inheritance
    2. Protected inheritance
    3. Private inheritance
    4. None of the given
  16. In Protected Inheritance the public members of base class become ________ in derived class.

    1. Public
    2. Private
    3. Protected
    4. None of the given
  17. In resolution order compiler search firstly ________.

    1. Generic Template
    2. Partial Specialization
    3. Complete Specialization
    4. Ordinary function
  18. Compiler generated copy constructor performs ________.

    1. Shallow copy
    2. Deep copy
    3. Both Shallow and Deep copy
    4. None of the given
  19. A pure virtual function is a virtual function that

    1. causes its class to be abstract.
    2. returns nothing.
    3. is used in a derived class.
    4. takes no arguments.
  20. Methodologies to the development of reusable software relate to ________.

    1. Structure programming
    2. procedural programming
    3. generic programming
    4. None of the given
  21. In C++ generic programming is done using ________.

    1. Procedures
    2. Packages
    3. Templates
    4. None of the given
  22. Consider the code below,

    class class1{
    private:
    void func1();
    };
    class class2 : private class1 {
    };
    Function func1 of class1 is ________ in class2.

    1. public
    2. protected
    3. private
    4. None of the given
  23. When derived class has user defined assignment operator.

    1. Compiler itself calls base class assignment operator.
    2. Compiler itself calls base class copy constructor.
    3. Compiler itself calls base class default constructor.
    4. Compiler does nothing.
  24. A Child class can call constructor of its parent class through,

    1. Its constructor initialization list
    2. Its constructor body
    3. Both from its constructor initialization list or body
    4. Can not call the constructor of its parent class
  25. Consider the code below,
    class class1{
    public:
    int i;
    };
    class class2 : public class1 {
    };

    Then int member i of class1 is ________ in class2.

    1. public
    2. protected
    3. private
    4. None of the given
  26. Consider the code below,
    class class1{
    protected:
    int i;
    };
    class class2 : private class1 {
    };

    Then int member i of class1 is ________ in class2.

    1. public
    2. protected
    3. private
    4. None of the given
  27. Static casting is,

    1. Implicit way of calling base class functions from derived class
    2. Explicit way of calling base class functions from derived class
    3. Both of the given
    4. None of the given
  28. How many objects of a given class may be constructed in an application?

    1. Only one per constructor.
    2. As many as the application asks for
    3. Only one per class
    4. One object per variable
  29. The other name of specialization is ________.

    1. Restriction
    2. Extension
    3. Dependency
    4. Subtyping
  30. How can we differentiate between constructors and destructors?

    1. Destructors have a return type but Constructors do not have return type.
    2. Destructors can't be defined by the programmer, but Constructors can be defined by the programmer.
    3. Destructors are preceded with a tilde (~) symbol, and constructors are not preceded with any symbol.
    4. Destructors are exactly same as Constructors in syntax.
  31. 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.

    1. 1
    2. 2
    3. 3
    4. 4
  32. Which of the following is True about Destructor?

    1. It is used to free memory that is allocated through dynamic allocation.
    2. Free memory allocated using new operator by over self in destructor.
    3. It is used to perform house keeping operations.
    4. All of the given
  33. How many objects are involved in the N-ary association?

    1. More than 1
    2. More than 2
    3. More than 3
    4. More than 4
  34. Which of the following can be the behavior of an object "Usman"?

    1. Name
    2. Age
    3. Address
    4. Eat
  35. In C++, Composition is a relationship between ________ and ________ objects.

    1. Parent, child
    2. Base, derived
    3. Whole, part
    4. All of the given
  36. 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 ________.

    1. B, A
    2. A, B
    3. A, C
    4. B, C
  37. In case when we define the function outside the class then we must use the keyword ________ to make the function inline.

    1. requestin
    2. inlineout
    3. inline
    4. defineinline
  38. Mermaid is an example of:

    1. Single inheritance
    2. Polymorphism
    3. Specialization
    4. Multiple Inheritance
  39. Assignment operators are:

    1. Left associative
    2. Right associative
    3. Left and right associative
    4. Non associative
  40. Generalization is ________ approach.

    1. Bottom-up
    2. Top-bottom
    3. Right-Left
    4. Left-Right
  41. The ________ tells the compiler what task the function will be performing.

    1. Function declaration
    2. Function calling
    3. Function definition
    4. None of the given
  42. Suppose str1, str2 and str3 are objects of class String. Choose appropriate declaration of overloaded assignment operator for the following statement to work correctly.

    1. void operator =(const String &);
    2. String& operator =(const String &);
    3. String& overload =(const String &);
    4. void op =(const String &);
  43. In operator overloading, which of the following operator takes one or no argument.

    1. ++
    2. *
    3. %
    4. <<
  44. Class is blueprint of ________.

    1. Interface
    2. Class
    3. Objects
    4. Model
  45. Polymorphism makes the system:

    1. reusable
    2. flexible
    3. faster
    4. All of the given
  46. If class B inherits from class A then it contains all characteristics of ________.

    1. Class B
    2. Class A
    3. No inheritance
    4. None of the given
  47. What is meant by multiple inheritance?

    1. Deriving a base class from derived class
    2. Deriving a derived class from base class
    3. Deriving a derived class from more than one base class
    4. None of the given
  48. In C++, which of the following operator can only be overloaded as a member function of the class?

    1. Equality Operator: ==
    2. Inequality Operator: !=
    3. Function Operator: ()
    4. Stream Extraction Operator: >>
  49. Insertion operator is ________ associative.

    1. Right to Left
    2. Left to Right
    3. Left to Left
    4. Right to Right
  50. In expression c1*c2+c3-c4 which of the following will be executed in first order?

    1. c1*c2
    2. c2+c3
    3. c3-c4
    4. c1-c4
  51. 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.

    1. Program will compile successfully.
    2. Compiler will generate compile time error.
    3. Run time error will be generated.
    4. None of the given
  52. Identify the abstract class from the given statement:

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

    1. Vehicle
    2. Bus
    3. Car
    4. Truck
  53. Which of the following operators operate on one operand?

    1. Binary Operators
    2. Unary Operators
    3. Ternary Operator
    4. All of the given
  54. Subtyping means that derived class is behaviorally ________ with the base class.

    1. Same
    2. Compatible
    3. Different
    4. Incompatible
  55. In ________, Base class can't always be replaced by the derived class.

    1. Aggregation
    2. Inheritance
    3. Specialization
    4. Extension
  56. The overloaded '-' operator for Complex class will be called with reference to ________ in the following statement
    Complex C3 = C1 - C2;

    1. Complex
    2. C1
    3. C2
    4. C3
  57. What is a class?

    1. A class is a section of computer memory containing objects
    2. A class is a section of the hard disk reserved for object oriented programs
    3. A class is the part of an object that contains the variables
    4. A class is a description of a kind of object
  58. In polymorphism, messages can be interpreted in different ways depending upon the ________ class.

    1. base
    2. derived
    3. sender
    4. receiver
  59. Suppose there is an object of type Person, which of the following can be considered as one of its attributes?

    1. Name
    2. Eat
    3. Work
    4. Sleep
  60. Which of the following is True about class?

    1. It is a mechanism in C++ to realize objects in a program.
    2. It is concrete implementation of objects in C++
    3. It is used to create new types in C++ according to our requirement
    4. All of the given
  61. In C++, which of the following keywords works only with constructors?

    1. const
    2. static
    3. explicit
    4. virtual
  62. Choose correct declaration of overloaded stream insertion operator for class String as non-member friend function.

    1. friend ostream & operator << ();
    2. friend void & operator << (ostream & os);
    3. friend void operator << (const String & rhs);
    4. friend ostream & operator << (ostream & os, const String & s);
  63. Which of the following classes are used by Amphibious vehicle to inherit characteristics?

    1. Land Vehicle
    2. Water Vehicle
    3. Both Land & Water Vehicle
    4. None of the given
  64. Constructors have ________ return type.

    1. int
    2. char
    3. void
    4. no
  65. The other name of specialization is ________.

    1. Restriction
    2. Extension
    3. Dependency
    4. Subtyping
  66. ________ is represented by a line with an unfilled diamond head towards the container.

    1. Inheritance
    2. Association
    3. Aggregation
    4. Composition
  67. ________ remain in memory even when all objects of a class have been destroyed.

    1. Static Variables
    2. Instance Variables
    3. Primitive Variables
    4. None of the given
  68. Static Data Member is declared ________.

    1. Inside the class
    2. Outside the class
    3. Inside main() method
    4. None of the given
  69. A good model is ________ related to a real life problem.

    1. Loosely
    2. Openly
    3. Closely
    4. Not
  70. In which of the following OOP paradigm objects cannot exist independently?

    1. Polymorphism
    2. Inheritance
    3. Aggregation
    4. Composition
  71. In order to make any function constant, keyword const is placed at the ________ of the parameter list.

    1. Beginning
    2. Middle
    3. End
    4. None of the given
  72. "Student registers Course and Teacher teaches the Course." is an example of:

    1. Binary Association
    2. Two way Association
    3. Ternary Association
    4. N-ary Association
  73. Which of the following can be the attribute of an object "Ali"?

    1. Eat
    2. Walk
    3. Sleep
    4. Address
  74. Consider the statement "room has chair" Which of the following type of association exists between room and chair?

    1. Inheritance
    2. Composition
    3. There is no association
    4. Aggregation
  75. We can access a private static variable through:

    1. Static data member
    2. Static member function
    3. Global data member
    4. None of the given
  76. Abstraction provides information according to ________.

    1. User perspective
    2. Owner perspective
    3. Random information
    4. All information
  77. Which of the following concept is more close to encapsulation?

    1. Exception Handling
    2. Inheritance
    3. Polymorphism
    4. Information Hiding
  78. How the information hidden within an object can be accessed?

    1. Through its interface
    2. Through its private data members
    3. Through its private member functions
    4. Through both public and private members
  79. ________ defines the order of evaluation of an operator in an expression.

    1. Operator Associativity
    2. Operator Precedence
    3. Arity of Operators
    4. None of the given
  80. Which of the following is the correct syntax of declaring static variable "count" of type int?

    1. static count int;
    2. static int count;
    3. int static count;
    4. int count static;
  81. Defining a function in class body, the compiler treats that function as:

    1. User defined function
    2. Static function
    3. Recursive function
    4. Inline function
  82. What is the output of the following code?

    int main()
    {
    int const x = 10;
    cout << ++x;
    return 0;
    }

    1. 10
    2. 11
    3. Error
    4. None of the given
  83. Which of the following statements best describes the Constructor?

    1. Constructor is used to modify constant data members of the class.
    2. Constructor is used to delete the objects of a class.
    3. Constructor is used to initialize the data members of a class.
    4. All of the given
  84. 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?

    1. 5, 5, 5
    2. 5, Junk value, 5
    3. Junk value, 5, Junk value
    4. Junk value, 5, 5
  85. Which of the following is a strong relationship?

    1. Inheritance
    2. Composition
    3. Association
    4. Polymorphism

Post a Comment

0Comments

Thanks everone

Post a Comment (0)