CS304 Object-Oriented Programming Final Exam
45 Questions
0 Views

Choose a study mode

Play Quiz
Study Flashcards
Spaced Repetition
Chat to lesson

Podcast

Play an AI-generated podcast conversation about this lesson

Questions and Answers

Which of the following causes run time binding?

  • Declaring object of abstract class
  • Declaring overridden methods as non-virtual (correct)
  • Declaring pointer of abstract class
  • None of the given
  • Which of the following is the best approach if it is required to have more than one functions having exactly same functionality and implemented on different data types?

  • Templates (correct)
  • Overloading
  • Encapsulation
  • Data hiding
  • A copy constructor is invoked when

  • a function returns by reference.
  • a function do not returns by value.
  • an argument is passed by reference.
  • an argument is passed by value. (correct)
  • Like template functions, a class template may not handle all the types successfully.

    <p>True</p> Signup and view all the answers

    A class template may inherit from another class template.

    <p>True</p> Signup and view all the answers

    By default the vector data items are initialized to ________.

    <p>0.0</p> Signup and view all the answers

    In private ______ only member functions and friend classes or functions of a derived class can convert pointer or reference of derived object to that of parent object.

    <p>inheritance</p> Signup and view all the answers

    Which one of the following terms must relate to polymorphism?

    <p>Dynamic binding</p> Signup and view all the answers

    By default the vector data items are initialized to

    <p>0</p> Signup and view all the answers

    A function template can not be overloaded by another function template.

    <p>True</p> Signup and view all the answers

    Which of the following is the best approach to implement generic algorithms with minimum number of coding lines?

    <p>Templates</p> Signup and view all the answers

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

    <p>A<char> obj;</p> Signup and view all the answers

    The user must define the operation of the copy constructor.

    <p>True</p> Signup and view all the answers

    Default constructor is such constructor which either has no ---------or if it has some parameters these have -------- values

    <p>Parameter, default</p> Signup and view all the answers

    The type that is used to declare a reference or pointer is called its

    <p>static type</p> Signup and view all the answers

    How the information hidden within an object can be accessed?

    <p>Through both public and private members</p> Signup and view all the answers

    The sub-object's life is not dependant on the life of master class in

    <p>Aggregation</p> Signup and view all the answers

    Encapsulation means

    <p>Data and behaviour are tightly coupled within an entity</p> Signup and view all the answers

    Algorithms can only be implemented using STL containers.

    <p>False</p> Signup and view all the answers

    When we write a class template the first line must be:

    <p>template &lt;class T &gt;</p> Signup and view all the answers

    An STL container can not be used to,

    <p>compile c++ programs.</p> Signup and view all the answers

    Consider a class named Vehicle, which of the following can be the instance of class Vehicle?

    <p>1, 5, 6</p> Signup and view all the answers

    Associativity can be changed in operator overloading.

    <p>False</p> Signup and view all the answers

    A normal C++ operator that acts in special ways on newly defined data types is said to be

    <p>overloaded</p> Signup and view all the answers

    Which operator can not be overloaded?

    <p>Conditional operator (?:)</p> Signup and view all the answers

    Suppose obj1 and obj2 are two objects of a user defined class A. An + operator is overloaded to add obj1 and obj2 using the function call obj1+obj2. Identify the correct function prototype against the given call?

    <p>A operator + ( A &amp;obj);</p> Signup and view all the answers

    Public methods of base class can --------be accessed in its derived class

    <p>directly</p> Signup and view all the answers

    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 nonvirtual member function, ding(), then the statement p->ding(); will cause the version of ding() in the ______ class to be executed.

    <p>Base</p> Signup and view all the answers

    When the base class and the derived class have a member function with the same name, you must be more specific which function you want to call (using ______ ).

    <p>scope resolution operator</p> Signup and view all the answers

    Non Template Friend functions of a class are friends of ______ instance/s of that class.

    <p>All</p> Signup and view all the answers

    In Private only member functions and friend classes or functions of a derived class can convert pointer or reference of derived object to that of parent object

    <p>inheritance</p> Signup and view all the answers

    In order to define a class template, the first line of definition must be:

    <p>template &lt;typename T&gt;</p> Signup and view all the answers

    In case of multiple inheritance a derived class inherits,

    <p>Both public data members and member functions of all its base classes</p> Signup and view all the answers

    Which of the following is incorrect line regarding function template?

    <p>Class&lt;template T&gt;</p> Signup and view all the answers

    Which of the following is/are advantage[s] of generic programming?

    <p>All of given</p> Signup and view all the answers

    Which one of the following functions returns the total number of elements in a vector.

    <p>size()</p> Signup and view all the answers

    Assume a class Derv that is privately derived from class Base. An object of class Derv located in main() can access

    <p>public members of Derv.</p> Signup and view all the answers

    Each try block can have __ no. of catch blocks.

    <p>As many as necessary.</p> Signup and view all the answers

    Two important STL associative containers are __ and __

    <p>set,map</p> Signup and view all the answers

    The mechanism of selecting function at run time according to the nature of calling object is called,

    <p>late binding</p> Signup and view all the answers

    An abstract class is useful when

    <p>We do not want to instantiate its object.</p> Signup and view all the answers

    Public methods of base class can __ be accessed in its derived class

    <p>directly</p> Signup and view all the answers

    Multiple inheritance can be of type___

    <p>All of the given</p> Signup and view all the answers

    When a subclass specifies an alternative definition for an attribute or method of its superclass, it is __ definition in the superclass.

    <p>overriding</p> Signup and view all the answers

    A function call is resolved at run-time in___

    <p>virtual member function.</p> Signup and view all the answers

    Study Notes

    CS304 Object-Oriented Programming Final Exam

    • Question 1 (Marks: 1): Which of the following causes run-time binding?

      • Declaring an object of an abstract class
      • Declaring a pointer of an abstract class
      • Declaring overridden methods as non-virtual
      • None of the given
    • Question 2 (Marks: 1): Which of the following is the best approach if it is required to have more than one function with the same functionality implemented on different data types?

      • Templates
      • Overloading
      • Data hiding
      • Encapsulation
    • Question 3 (Marks: 1): When is a copy constructor invoked?

      • A function does not return by value
      • An argument is passed by value
      • A function returns by reference
      • An argument is passed by reference
    • Question 4 (Marks: 1): Can a class template not handle all the types successfully?

      • True
      • False
    • Question 6 (Marks: 1): Can a class template inherit from another class template?

      • True
      • False
    • Question 7 (Marks: 1): By default, what value are vector data items initialized to?

      • 0
      • 0.0
      • 1
      • null
    • Question 8 (Marks: 1): In Private, derived classes can convert parent pointers?

      • specialization
      • inheritance
      • abstraction
      • composition
    • Question 9 (Marks: 1): Which is/are an advantage(s) of generic programming?

      • Reusability
      • Writability
      • Maintainability
      • All of the given
    • Question 10 (Marks: 1): What do template functions use compared to ordinary functions?

      • Greater Memory
      • Lesser Memory
      • Equal Memory
      • None of the given options
    • Question 11 (Marks: 1): Which are friends of non-template friend functions?

      • All instances
      • One specific instance
      • All instances of one type of data
      • None of the given options
    • Question 12 (Marks: 1): When is a copy constructor invoked?

      • A function does not return a value
      • An argument is passed by value
      • A function returns by reference
      • An argument is passed by reference
    • Question 13 (Marks: 1): Can a pointer to a base class point to objects of a derived class?

      • True
      • False
    • Question 14 (Marks: 1): What keyword precedes a template argument?

      • vector
      • class
      • template
      • type*
    • Question 15 (Marks: 1): Which term relates to polymorphism?

      • Static allocation
      • Static typing
      • Dynamic binding
      • Dynamic allocation
    • Question 16 (Marks: 1): Which of the following is a multiple inheritance type?

      • Public
      • Private
      • Protected
      • All of the given
    • Question 17 (Marks: 1): If a class is privately derived from another class, which members of the derived class can be accessed from main?

      • Public members of the derived class
      • Protected members of the derived class
      • Private members of the derived class
      • Protected members of the base class
    • Question 18 (Marks : 1 ): When is a copy constructor invoked?

      • A function doesn't return by value
      • An argument is passed by value
      • A function returns by reference
      • An argument is passed by reference
    • Question 19 (Marks: 1): When does a function call resolve in runtime?

      • Non-virtual member function
      • Virtual member function
      • Both non-virtual and virtual member functions
      • None of the given
    • Question 20 (Marks: 1): What are two important STL associative containers?

      • set, map
      • sequence, mapping
      • setmet, multiple
      • sit, mat
    • Question 21 (Marks: 1): When is an abstract class useful?

      • We don't derive any class from it
      • There are multiple paths from one derived class to another
      • We don't want to instantiate an object
      • You want to defer the declaration of the class
    • Question 22 (Marks: 1): Which of the following is an advantage of generic programming?

      • Reusability
      • Writability
      • Maintainability
      • All of the given
    • Question 23 (Marks: 1): What is the default initialization value of vector data items?

      • 0
      • 0.0
      • 1
      • null
    • Question 24 (Marks: 1): Which of the following are advantages of generic programming?

      • Reusability
      • Writability
      • Maintainability
      • All of the given
    • Question 25 (Marks: 1): What are the default initial values of vectors?

      • 0
      • 0.0
      • 1
      • null
    • Question 26 (Marks: 1): CS304- Object Oriented Programming (Session - 3)

    • Question 27 (Marks: 1): How to declare template class as a friend?

    • Question 28(Marks: 1): TwoDimensionalShape and ThreeDimensionalShape vs Sphere and Cube

      • True
      • False
    • Question 29 (Marks: 1): How to define a class template definition?

    • Question 30(Marks: 1): What does a derived class inherit in multiple inheritance?

    • Question 31 (Marks: 1): In private inheritance, the derived class can convert…

    • Question 32 (Marks: 1): Which is best approach if functions have same functionality but different types?

    • Question 33 (Marks: 1): What is the benefit of a subclass defining its own sub-classes instead of just its super-classes method?

    • Question 34 (Marks: 1): How many catch blocks can accommodate a single try block?

    • Question 35 (Marks: 1): What is the graphical representation of objects and classes named?

    • Question 36 (Marks: 1) Destructor function overloading:

      • True
      • False
    • Question 37 (Marks: 1): What is the behavior of a pointer to a base class that points to an object of a derived class regarding member function calls?

    • Question 38 (Marks: 1): Which operator cannot be overloaded ?

    • Question 39 (Marks: 1): Which of the following may not be an integral part of an object?

    • Question 40 (Marks:1): What is late binding?

    • Question 41 (Marks: 1): What is static binding?

    • Question 42 (Marks: 1): What is the role of a virtual function?

    • Question 43 (Marks: 1): How is an abstract class usefull?

    • Question 44 (Marks: 1): What is the advantage of having a template functions

    • Question 45 (Marks: 1): How many catch blocks can accommodate a single try block?

    • Question 46 (Marks : 1 ): How the information hidden within an object can be accessed?

    Studying That Suits You

    Use AI to generate personalized quizzes and flashcards to suit your learning preferences.

    Quiz Team

    Related Documents

    Description

    Test your knowledge with this final exam for CS304 on Object-Oriented Programming. This quiz covers key concepts such as templates, run-time binding, and copy constructors. Prepare to evaluate your understanding of OOP principles and practices.

    More Like This

    Use Quizgecko on...
    Browser
    Browser