In the name of ALLAH, the most beneficient, the most merciful

Object Oriented Programming (CS304)

Multiple Choice Questions (MCQs)

Objective Questions

  1. 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
  2. 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
  3. In polymorphism, messages can be interpreted in different ways depending upon the ________ class.

    1. base
    2. derived
    3. sender
    4. receiver
  4. 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
  5. 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
  6. In C++, which of the following keywords works only with constructors?

    1. const
    2. static
    3. explicit
    4. virtual
  7. 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);
  8. 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
  9. Constructors have ________ return type.

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

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

    1. Inheritance
    2. Association
    3. Aggregation
    4. Composition
  12. ________ 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
  13. Static Data Member is declared ________.

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

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

    1. Polymorphism
    2. Inheritance
    3. Aggregation
    4. Composition
  16. 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
  17. "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
  18. Which of the following can be the attribute of an object "Ali"?

    1. Eat
    2. Walk
    3. Sleep
    4. Address
  19. 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
  20. 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
  21. Abstraction provides information according to ________.

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

    1. Exception Handling
    2. Inheritance
    3. Polymorphism
    4. Information Hiding
  23. 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
  24. ________ 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
  25. 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;
  26. 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
  27. 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
  28. 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
  29. 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
  30. Which of the following is a strong relationship?

    1. Inheritance
    2. Composition
    3. Association
    4. Polymorphism
  31. 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
  32. The other name of specialization is ________.

    1. Restriction
    2. Extension
    3. Dependency
    4. Subtyping
  33. 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.
  34. 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
  35. 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
  36. 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
  37. Which of the following can be the behavior of an object "Usman"?

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

    1. Parent, child
    2. Base, derived
    3. Whole, part
    4. All of the given
  39. 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
  40. 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
  41. Mermaid is an example of:

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

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

    1. Bottom-up
    2. Top-bottom
    3. Right-Left
    4. Left-Right
  44. 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
  45. 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 &);
  46. In operator overloading, which of the following operator takes one or no argument.

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

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

    1. reusable
    2. flexible
    3. faster
    4. All of the given
  49. 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
  50. 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
  51. 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: >>
  52. Insertion operator is ________ associative.

    1. Right to Left
    2. Left to Right
    3. Left to Left
    4. Right to Right
  53. 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
  54. 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
  55. 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
  56. Which of the following operators operate on one operand?

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

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

    1. Aggregation
    2. Inheritance
    3. Specialization
    4. Extension