Object Oriented Programming

Object Oriented Programming – CS304

Question No: 1   ( Marks: 1 )   – Please choose one

Which part of an object exhibits its state?

  • Data
  • Operations
  • Any public part
  • Any private part

Question No: 2   ( Marks: 1 )   – Please choose one

Inheritance is a way to

  • organize data.
  • pass arguments to objects of classes.
  • add features to existing classes without rewriting them.
  • improve data-hiding and encapsulation.

Question No: 3 ( Marks: 1 ) – Please choose one Suppose you have been given the following design,

“A person has a name, age, address and sex. You are designing a class to represent a type of person called a patient. This kind of person may be given a diagnosis, have a spouse and may be alive”. Given that the person class has already been created, what of the following would be appropriate to include when you design the patient class?

  • registration date and diagnosis
  • age and sex
  • sex and diagnosis
  • diagnosis and age

Question No: 4   ( Marks: 1 )   – Please choose one

What problem(s) may occur when we copy objects without using deep copy constructor?

  • Dangling pointer
  • Memory Leakage
  • All of the given
  • System crash

Question No: 5   ( Marks: 1 )   – Please choose one

this pointers are not accessible for static member functions.

  • True
  • False

Question No: 6   ( Marks: 1 )   – Please choose one

A static member function cannot be declared.

  • Static
  • Implicit
  • Explicit
  • Virtual

Question No: 7   ( Marks: 1 )   – Please choose one

_______ remain in memory even when all objects of a class have been destroyed.

  • Static variables
  • Instance variable
  • Primitive variables
  • None of given

Question No: 8   ( Marks: 1 )   – Please choose one

Friend functions are _____________ functions of a class.

  • None of given
  • object member
  • non-member
  • data member

Question No: 9   ( Marks: 1 )   – Please choose one

___________, which means if A declares B as its friend it does NOT mean that A can access private data of B. It only means that B can access all data of A.

  • Friendship is one way only
  • Friendship is two way only
  • NO Friendship between classes
  • Any kind of friendship

Question No: 10   ( Marks: 1 )   – Please choose one

The statement objA=objB; will cause a compiler error if the objects are of different classes.

  • True
  • False

Question No: 11   ( Marks: 1 )   – Please choose one

Identify which of the following overloaded operator function’s declaration is appropriate for the given call?

Rational_number_1 + 2.325, Where Rational_number_1 is an object of user defined class Rational_number.

  • operator+(double& obj);
  • Rational_number operator+(Rational_number &obj, double& num);
  • Rational_number operator+(double& obj);
  • Rational_number operator+( Rational_number & obj);

Question No: 12   ( Marks: 1 )   – Please choose one

Which operator can not be overloaded?

  • The relation operator ( >= )
  • Assignment operator ( = )
  • Script operator ( [] )
  • Conditional operator (? : )

Question No: 13   ( Marks: 1 )   – Please choose one

To convert from a user-defined class to a basic type, you would most likely use

  • a built-in conversion operator.
  • a one-argument constructor.
  • an overloaded = operator.
  • a conversion operator that’s a member of the class.

Question No: 14   ( Marks: 1 )   – Please choose one

The technique in which we visualize our programming problems according to real life’s problems is called

► structured programming

► object oriented Programming      

► procedural programming

► non of the given

Question No: 15   ( Marks: 1 )   – Please choose one

In object orientated programming, a class of objects cans _____________ properties from another class of objects

  • Utilize
  • Borrow
  • Inherit
  • Adopt

Question No: 16   ( Marks: 1 )   – Please choose one

A C++ class is similar to ——————–

  • Header File
  • Structure
  • Library File
  • None of the given

Question No: 17   ( Marks: 1 )   – Please choose one

What problem(s) may occur when we copy objects without using deep copy constructor?

  • Dangling pointer
  • Memory Leakage
  • All of the given
  • System crash

Question No: 18   ( Marks: 1 )   – Please choose one

Suppose that the Test class does not have an overloaded assignment operator. What happens when an assignment a=b; is given for two Test objects a and b?

  • Compiler error
  • The copy constructor is used
  • The automatic assignment operator is used
  • Run-time error

Question No: 19   ( Marks: 1 )   – Please choose one

a’A static member function can be called, even when a class is not __________.

  • Declared
  • Define
  • Instantiated
  • Called

Question No: 20   ( Marks: 1 )   – Please choose one

Identify which of the following overloaded operator function’s declaration is appropriate for the given call?

Rational_number_1 + 2.325, Where Rational_number_1 is an object of user defined class Rational_number.

  • Rational_number operator+(Rational_number &obj, double& num);
  • Rational_number operator+(double& obj);
  • Rational_number operator+( Rational_number & obj);
  • operator+(double& obj);

Question No: 21   ( Marks: 1 )   – Please choose one

__________ provide the facility to access the data member.

  • accesser function
  • private function
  • inline function
  • None of the given

Question No: 22  ( Marks: 1 )   – Please choose one

Constant objects cannot change their state,

  • True  
  • False

Question No: 23   ( Marks: 1 )   – Please choose one

The ________ relationship indicates that an object contains other objects.

  • ‘has-a’
  • ‘is-a’
  • None of given
  • ‘be-

Question No: 24   ( Marks: 1 )   – Please choose one

Which one of the following features of OOP is used to derive a class from another?

  • Encapsulation
  • Polymorphism
  • Data hiding
  • Inheritance

Question No: 25   ( Marks: 1 )   – Please choose one

_______ is a relationship

  • Polymorphism
  • Inheritance
  • abstraction
  • encapsulation

Question No: 26   ( Marks: 1 )   – Please choose one

__________ satisfy the condition of polymorphism

  • Carbon
  • Diamond
  • Coal
  • all of the given    

Question No: 27   ( Marks: 1 )   – Please choose one

A generalization-specialization relation between classes are implemented using

  • data hiding
  • friend classes
  • encapsulation
  • inheritance

Question No: 28   ( Marks: 1 )   – Please choose one

The >= operator can be overloaded.

► True     

► False

Question No: 29   ( Marks: 1 )   – Please choose one

In order to free the memory occupied by the object, we use ————-

  • Constructor
  • Destructor
  • Shallow Copy
  • Deep Copy

Question No: 30  ( Marks: 1 )   – Please choose one

Which of the following is not an example of multiple inheritances?———-

  • Mermaid
  • Woman
  • None of the given
  • Amphibious Vehicle

Question No: 31   ( Marks: 1 )   – Please choose one

Static variable can be initialized more than once.

  • True
  • False

Question No: 32   ( Marks: 1 )   – Please choose one

A generic class showing all the common attributes and a behavior of other classes represents a very important feature in oop called ——–

  • Inheritance
  • Encapsulation
  • Polymarphism
  • Abstraction

Question No: 33   ( Marks: 1 )   – Please choose one

We can get only one unique value which can be used by all the objects of that class by the use of,

►static variables

►dynamic variables

►instance variables

►data members

Question No: 34  ( Marks: 1 )   – Please choose one

A member function having the same name as that of a class and a ~ sign with it is called,

►Constructor

►Getter

►Setter

►Destructor

Question No: 35  ( Marks: 1 )   – Please choose one

Static variable can be initialized more than once.

True

False

Question No: 36 ( Marks: 1 )   – Please choose one

For classes with common behavior, you can save effort by placing the common behavior in a __________.

►Derived Class

►Base class   

►Deprived Class

►Named class

Question No: 37 ( Marks: 1 ) – Please choose one

Which of the following are an advantage of OOP?

►OOP makes it easy to re-use the code

►It provides an ability to create one user defined data type by extending the other

►It provides the facility of defining Abstract data types through which real world entities can be defined better.

►All of the given options      

Question No: 38  ( Marks: 1 )   – Please choose one

The >= operator can be overloaded.

►True    

►False

Question No: 39  ( Marks: 1 )   – Please choose one

A static member function cannot be declared.

►Static

►Implicit

►Explicit

►Virtual       

Question No: 40  ( Marks: 1 )   – Please choose one

Static variables act like a global variable in the context or scope of the class.

►True   

►False

Question No: 41  ( Marks: 1 )   – Please choose one

The compiler won’t object if you overload the * operator to perform division.

►True      

►False

Question No: 42  ( Marks: 1 )   – Please choose one

We can use “this” pointer in the constructor in the body and even in the initialization list of any class if we are careful,

►TRUE

►False

Question No: 43: ( Marks: 1 )   – Please choose one

Which operator can not be overloaded?

►The relation operator ( >= )

►Assignment operator ( = )

►Script operator ( [] )

►Conditional operator (? : )   

Question No: 44 ( Marks: 1 )   – Please choose one

An overloaded operator always requires one less argument than its number of operands.

►True

►False

Question No: 45 ( Marks: 1 )   – Please choose one

A generalization-specialization relation between classes are implemented using

►data hiding

►friend classes

►encapsulation

►inheritance   

Question No: 46  ( Marks: 1 )   – Please choose one

A class can be identified from a statement by ————-

►Noun  

►Pronoun

►Verb

►Adverb

Question No: 47  ( Marks: 1 )   – Please choose one

The members of a class that can be accessed without creating the object of the class is called

►Private member

►Data Member

Public Member     

►Static

Question No: 47 ( Marks: 1 ) – Please choose one

Suppose there is an object of type Person, which of the following can be considered as one of its attributes

  • Name
  • Age
  • Work()
  • Both Name and Age

Question No: 48 ( Marks: 1 ) – Please choose one

What a derived class can add?

  • New data members
  • New member functions and New friend functions
  • New constructors and destructor
  • All of given

Question No: 49 ( Marks: 1 ) – Please choose one

________ is/are used to access information hidden within an object?

  • Interface
  • Private data members
  • Private member functions
  • Both public and private members

Question No: 50 ( Marks: 1 ) – Please choose one

this pointers are not accessible for static member functions.

  • True
  • False

Question No: 51 ( Marks: 1 ) – Please choose one

A static member function cannot be declared.

  • Static
  • Implicit
  • Explicit
  • Virtual

Question No: 52 ( Marks: 1 ) – Please choose one

C++ compiler does not allow to dynamically allocate memory for object

  • False
  • True

Question No: 53 ( Marks: 1 ) – Please choose one Given the following class

class Base{ int Age=33; }

How you can improve above class with respect to accessing the field Age?

  • Define the variable Age as private
  • Define the variable Age as protected
  • Define the variable Age as private and create a get method that returns it and a set method that updates it
  • Define the variable Age as protected and create a set method that returns it and a get method that updates it

Question No: 54 ( Marks: 1 ) – Please choose one

Friend class and friend function can be used as an alternate to each other

► True

► False

Question No: 55 ( Marks: 1 ) – Please choose one

Which of the following operators always takes no argument if overloaded?

  • /
  • +
  • ++

Question No: 56 ( Marks: 1 ) – Please choose one

Suppose that the Test class does not have an overloaded assignment operator. What happens when an assignment a=b; is given for two Test objects a and b?

  • Compiler error
  • The automatic assignment operator is used
  • The copy constructor is used
  • Run-time error

Question No: 57 ( Marks: 1 ) – Please choose one

Assume a class C with objects obj1, obj2, and obj3. For the statement obj3 = obj1 – obj2 to work correctly, if the overloaded – operator must

  • return a value
  • take two arguments
  • create a named temporary object.
  • take four arguments

Question No: 58 ( Marks: 1 ) – Please choose one

Which operator can not be overloaded?

  • The relation operator ( >= )
  • Assignment operator ( = )
  • Script operator ( [] )
  • Conditional operator (? : )

Question No: 59 ( Marks: 1 ) – Please choose one

We achieve independence of internal implementation from its external interface through———–

  • Encapsulation
  • Information Hiding
  • Abstraction
  • both encapsulation and information hiding

Question No: 60 ( Marks: 1 ) – Please choose one

Which one of the following is not an object association?

  • Aggregation
  • Simple Association
  • Inheritance
  • Composition

Question No: 61 ( Marks: 1 ) – Please choose one

We capture the object attributes and behavior in Object Oriented programming using—————

  • Class
  • Function
  • Data Members
  • Instances

Question No: 62 ( Marks: 1 ) – Please choose one

The return type of a constructor is of ————-

  • Integer
  • Chracter
  • Double
  • No type