Thursday , 21 November 2024

CS304 Solved MCQs For Mid Term papers

VU assignments.com will provide you all type of Old Papers and Solved MCQs of CS304 and all other subjects. Take the following MCQs as an Idea and also Try to solved these MCQs yourself for better Preparation of Upcoming Quizs and Mid term Papers

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.

Select correct option:

  1. Rational_number operator+( Rational_number & obj);
  2. None of the given choices
  3. Rational_number operator+(Rational_number &obj, double& num);
  4. operator+(double& obj);

 

In _______________ a pointer or reference to an object is created inside a class
Select correct option:

  1. Aggregation 
  2. Composition
  3. Seperation
  4. None of the given

Sub-Object can not be initialized using the constructor
Select correct option:

  1. True
  2. False 

To initialize an array of objects, only _____________ will be called
Select correct option:

  1. Defualt Constructor
  2. Overloaded Constructor
  3. Default Object
  4. None of the above

Let Suppose a class Student with objects std1, std2, and std3. For the statement std3 = std1 – std2 to work correctly, if the overloaded – operator must
Select correct option:

  1. take two arguments.
  2. None of the given choices 
  3. take single argument
  4. take three arguments

Copy constructor is called when:
Select correct option:

  1. An object is created in term of pre existence object
  2. An object is created
  3. An object is initialized
  4. None of the given

Which of the following operator doesn’t take any argument if overloaded?
Select correct option:

  1. /
  2. +
  3. None of the given choices

Object can be declared constant with the use of Constant keyword.
Select correct option:

  1. True 
  2. False

Always make pointer to null, whenever dynamic memory is deleted.
Select correct option:

  1. True 
  2. False

__________ provide the facility to access the data member.
Select correct option:
accesser function
private function
inline function
None of the given

Person” class is composed off “Nationality” class. What will be the order of execution of constructor of “Keyboard” class and “Keys” class

  1. First Constructor:: Nationality..
  2. Second Constructor:: Person..
  3. First Constructor:: Person..
  4. Second Constructor:: Nationality..

The direction specifies which object contains the other object. In aggregation direction is must

  1. Yes
  2. No

Select correct line of code for inheritance relationship between “Account” class and “SavingAccount” class. “Account” is parent class while “SavingAccount” is child clas

  1. class SavingAccount : public Account
  2. class Account: public SavingAccount
  3. class SavingAccount :: public Account
  4. class Account :: public SavingAccount

Select correct line of code for inheritance relationship between “Gender” class and “Male” class. “Gender” is parent class while “Male” is child class.

Select correct option:

  1. class Male: public Gender
  2. class Gender: public Male
  3. class Male:: public Gender
  4. class Gender:: public Male

In______________, a pointer or reference to an object is created inside a class.

Select correct option:

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

 

Select correct line of code for inheritance relationship between “Person” class and “Supervisor” class. “Person” is parent class while “Supervisor” is child class.

Select correct option:

 

  1. class Supervisor: public Person
  2. class Person: public Supervisor
  3. class Supervisor:: public Person
  4. class Person:: public Supervisor

The direction specifies which object contains the other object. In composition direction is must.

  1. No
  2. Yes

 

Select correct line of code for inheritance relationship between “Keys” class and “SpecialKeys” class. “Person” is parent class while “SpecialKeys” is child class.

Select correct option:

 

  1. class SpecialKeys: public Keys
  2. class Keys: public SpecialKeys
  3. class SpecialKeys:: public Keys
  4. class Keys:: public SpecialKeys

 

“Keyboard” class is composed off “keys” class. What will be the order of execution of destructor of “Keyboard” class and “Keys” class?

Select correct option:

 

  1. First Detructor::Keys..
  2. Second Destructor::Keyboard..
  3. First Destructor:: Keyboard..
  4. Second Destructor:: Keys..

 

“A fan has wings”. Which type of relationship exists between fan and wings?

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

 

What type of relationship exists between “Account” class and “SavingAccount” class?

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

 

Select correct line of code for inheritance relationship between “Nationality” class and “Citizen” class. “Nationality” is parent class while “Citizen” is child class.

  1. class Citizen: public Nationality
  2. class Nationality: public Citizen
  3. class Citizen:: public Nationality
  4. class Nationality:: public Citizen

“Keyboard” class is composed off “keys” class. What will be the order of execution of destructor of “Keyboard” class and “Keys” class

  1. First Detructor::Keys..
  2. Second Destructor::Keyboard..
  3. First Destructor:: Keyboard..
  4. Second Destructor:: Keys..

Select correct line of code for inheritance relationship between “Keys” class and “StandardKeys” class. “Person” is parent class while “StandardKeys” is child class.

  1. class StandardKeys: public Keys
  2. class Keys: public StandardKeys
  3. class StandardKeys:: public Keys
  4. class Keys:: public StandardKeys

Select correct line of code for inheritance relationship between “Gender” class and “Male” class. “Gender” is parent class while “Male” is child class.

  1. class Male: public Gender
  2. class Gender: public Male
  3. class Male:: public Gender
  4. class Gender:: public Male

What will be most appropriate C++ data type for variable “InterestRate

  1. Int
  2. long int
  3. double
  4. float

Select correct line of code for composition relationship between “Keyboard” class and “Keys” class

  1. class keyboard { Keys type;};
  2. class keys{ KeyBoard type; };
  3. class keyboard : private keys
  4. class keys: private KeyBoard

Method “getInterestRate()” should belongs to class

  1. Account()
  2. SavingAccount()
  3. CurrentAccount()
  4. None of the given options

Can we access methods of composed object in the same way as we can access methods of other objects?

  1. Yes
  2. No

The sub-object’s life is not dependant on the life of master class in ___________.

  1. Composition
  2. Aggregation
  3. Seperation
  4. non of the given

 

correct line of code for inheritance relationship between “Nationality” class and “Foreigner” class. “Nationality” is parent class while

  1. “Foreigner” is child class.
  2. class Foreigner: public Nationality
  3. class Nationality: public Foreigner
  4. class Foreigner:: public Nationality

 

Select correct line of code for aggregation relationship between “Person” class and “Phone” class.

  1. class Person { Phone * p; };
  2. class Phone { Person * p; };
  3. class Person { Phone p; };
  4. class Phone { Person p; };

In ______________destructor of sub-object is called after destructor of master class.

smilechat: options

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

correct line of code for inheritance relationship between “Gender” class

and “Female” class. “Gender” is parent class while “Female” is child

class.

  1. class Female: public Gender
  2. class Gender: public Female
  3. class Female:: public Gender
  4. class Gender:: public Female

Account” is parent class while “CurrentAccount” is child class. Can I inherit the destructor of “account” class?

  1. Yes
  2. no

 

Select correct line of code for inheritance relationship between “Gender” class and “Male” class. “Gender” is parent class while “Male” is child class.

  1. class Male: public Gender
  2. class Gender: public Male
  3. class Male:: public Gender
  4. class Gender:: public Male

 

 

What will be most appropriate C++ data type for variable “InterestRate

  1. Int
  2. long int
  3. double
  4. float


Select correct line of code for composition relationship between “Keyboard” class and “Keys” class

  1. class keyboard { Keys type;};
  2. class keys{ KeyBoard type; };
  3. class keyboard : private keys
  4. class keys: private KeyBoard


Method “getInterestRate()” should belongs to class

  1. Account()
  2. SavingAccount()
  3. CurrentAccount()
  4. None of the given options


Can we access methods of composed object in the same way as we can access methods of other objects?

  1. Yes
  2. No


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.

Select correct option:

  1. Rational_number operator+( Rational_number & obj);
  2. None of the given choices
  3. Rational_number operator+(Rational_number &obj, double& num);
  4. operator+(double& obj);

 

In _______________ a pointer or reference to an object is created inside a class

Select correct option:

  1. Aggregation
  2. Composition
  3. Seperation
  4. None of the given

 

Sub-Object can not be initialized using the constructor

Select correct option:

  1. True
  2. False

 

To initialize an array of objects, only _____________ will be called

Select correct option:

  1. Defualt Constructor
  2. Overloaded Constructor
  3. Default Object
  4. None of the above

 

Let Suppose a class Student with objects std1, std2, and std3. For the statement std3 = std1 – std2 to work correctly, if the overloaded – operator must

Select correct option:

  1. take two arguments.
  2. None of the given choices
  3. take single argument
  4. take three arguments

 

Copy constructor is called when:

Select correct option:

  1. An object is created in term of pre existence object
  2. An object is created
  3. An object is initialized
  4. None of the given

 

Select correct line of code for aggregation relationship between “Person” class and “Address” class.

  1. class Person { Address * a; };
  2. class Address { Person * a; };
  3. class Person { Address a; };
  4. class Address { Person a; };

In ______________constructors of the sub-objects are always executed before the constructors of the master class.

Select correct option:

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

What will be most appropriate C++ data type for variable “MinimumBalance”?

Select correct option:

  1. int
  2. long int
  3. float
  4. double

The direction specifies which object contains the other object. In aggregation direction is must

  1. Yes
  2. No

Select correct line of code for inheritance relationship between “Account” class and “SavingAccount” class. “Account” is parent class while “SavingAccount” is child clas

  1. class SavingAccount : public Account
  2. class Account: public SavingAccount
  3. class SavingAccount :: public Account
  4. class Account :: public SavingAccount

“Keyboard” class is composed off “keys” class. What will be the order of execution of destructor of “Keyboard” class and “Keys” class

  1. First Detructor::Keys..
  2. Second Destructor::Keyboard..
  3. First Destructor:: Keyboard..
  4. Second Destructor:: Keys..

Select correct line of code for inheritance relationship between “Keys” class and “StandardKeys” class. “Person” is parent class while “StandardKeys” is child class.

  1. class StandardKeys: public Keys
  2. class Keys: public StandardKeys
  3. class StandardKeys:: public Keys
  4. class Keys:: public StandardKeys
  5. Object can be declared constant with the use of Constant keyword.

Select correct option:

  1. True
  2. False

 

Always make pointer to null, whenever dynamic memory is deleted.

Select correct option:

  1. True
  2. False

__________ provide the facility to access the data member.

Select correct option:

  1. accesser function
  2. private function
  3. inline function
  4. None of the given

 

_____ is creating objects of one class inside another class.

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

 A template provides a convenient way to make a family of 

Select correct option:

  1. variables and data members
  2. functions and classes
  3. classes and exceptions
  4. programs and algorithms

 

 

A class template may inherit from another class template.
Select correct option:

  1. True 
  2. False

 

 

Target of a _____ function call is determined at run time.
Select correct option:

  1. instance
  2. virtual 
  3. operator
  4. none of given

 

 

A class hierarchy
Select correct option:

  1. shows the same relationships as an organization chart.
  2. describes “has a” relationships.
  3. describes “is a kind of” relationships.
  4. shows the same relationships as a family tree.

 

Sender of the message does not need to know the exact class of receiver in______.
Select correct option:

  1. Abstraction
  2. Polymorphism 
  3. Inheritance
  4. none of the given

 

 

A function call is resolved at run-time in_________
Select correct option:

  1. non-virtual member function
  2. virtual member function
  3. Both non-virtual member and virtual member function.
  4. None of given

 

 

Adding a derived class to a base class requires fundamental changes to the base class.
Select correct option:

  1. True
  2. False

 

 User can make virtual table explicitly. 

Select correct option:

  1. True 
  2. False

 

 

Select correct line of code for aggregation relationship between “Person” class and “Address” class.

 

  1. class Person { Address * a; };
  2. class Address { Person * a; };
  3. class Person { Address a; };
  4. class Address { Person a; };

 

In ______________constructors of the sub-objects are always executed before the constructors of the master class.

 

Select correct option:

 

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

 

What will be most appropriate C++ data type for variable “MinimumBalance”?

 

Select correct option:

 

  1. int
  2. long int
  3. float
  4. double

 

The direction specifies which object contains the other object. In aggregation direction is must

 

  1. Yes
  2. No

Select correct line of code for inheritance relationship between “Account” class and “SavingAccount” class. “Account” is parent class while “SavingAccount” is child clas

 

  1. class SavingAccount : public Account
  2. class Account: public SavingAccount
  3. class SavingAccount :: public Account
  4. class Account :: public SavingAccount

 

“Keyboard” class is composed off “keys” class. What will be the order of execution of destructor of “Keyboard” class and “Keys” class

 

  1. First Detructor::Keys..
  2. Second Destructor::Keyboard..
  3. First Destructor:: Keyboard..
  4. Second Destructor:: Keys..

Select correct line of code for inheritance relationship between “Keys” class and “StandardKeys” class. “Person” is parent class while “StandardKeys” is child class.

 

  1. class StandardKeys: public Keys
  2. class Keys: public StandardKeys
  3. class StandardKeys:: public Keys
  4. class Keys:: public StandardKeys

 

 

 

Binding means that target function for a call is selected at compile time.
Select correct option:

  1. Static 
  2. Dynamic
  3. Automatic
  4. None of given

 

 Target of a _____ function call is determined at run time. 

Select correct option:

  1. instance
  2. virtual 
  3. operator
  4. none of given

 

 Which line will produce error. Class phone: private Transmit, private Receiver { } 1. int main() 2. { 3. phone obj; 4. Tranmit* obj1 = &obj; 5. Received obj2 = &obj; 6. } Select correct option: 

  1. 3rd line will produce error 
  2. 4th line will produce error 
  3. 3rd and 4th line will produce error. 
  4. 5th line will produce error

 

Function overriding is done in context of,
Select correct option:

  1. Single class
  2. Single derived class
  3. Single base class
  4. Derived and base classes

 

 Consider the code below, class class1{ public: void func1(); }; class class2 : protected class1 { }; Function func1 of class1 is ____ in class2, 

Select correct option:

  1. public
  2. protected 
  3. private
  4. none of the given options

 

 

the following statements: 1) int iArray[5]; 2) int *pArr = iArray;
Select correct option:

  1. These statements will compile successfully
  2. Error in first statement
  3. Error in second statement
  4. None of given options

 

 Methodologies to the development of reusable software relate to________

Select correct option:

  1. Structure programming
  2. procedural programming
  3. generic programming 
  4. None of the given

 

 

function template must have a parameter.
Select correct option:

  1. True
  2. False

 

 

The default inheritance mode is,
Select correct option:

  1. Public inheritance
  2. Protected inheritance
  3. Private inheritance 
  4. None of these options

 

 

Two functions with same names, parameters and return type can exist in,
Select correct option:

  1. Function overloading 
  2. Function overriding
  3. Operator overloading
  4. None of these options

 

 

Consider the code below, class c1{ }; class c2 : public c1 { }; class c3 : public c2 { }; Then c2 is, 
Select correct option: 

  1. Direct base class of c3 
  2. Direct child class of c3 
  3. Direct base class of c1 
  4. None of these

 

 Virtual functions allow you to 

Select correct option:

  1. create an array of type pointer-to-base class that can hold pointers to derived classes.
  2. create functions that can never be accessed.
  3. group objects of different classes so they can all be accessed by the same function code. 
  4. use the same function call to execute member functions of objects from different classes.

 

 User can make virtual table explicitly. 

Select correct option:

  1. True
  2. False

 

 

In order to define a class template the first line of definition must be:
Select correct option:

  1. template <typename T>
  2. typename <template T>
  3. Template Class <ClassName>
  4. Class <Template T>

 

 

Consider the following statements: 1) int iArray[5]; 2) int *pArr = iArray;
Select correct option:

  1. These statements will compile successfully
  2. Error in first statement
  3. Error in second statement 
  4. None of given options

 

 In c++ dynamic binding and polymorphism will be achieved when member function will be __

Select correct option:

  1. private
  2. public
  3. virtual 
  4. inline

 

 In type in depended function template should be use where code and behavior must be identical. 

Select correct option:

  1. True 
  2. False


 

Consider the code below, class class1{ protected: int i; }; class class2 : private class1 { }; Then int member i of class1 is ____ in class2,
Select correct option:

 

  1. public
  2. protected 
  3. private
  4. none of the given options

 

 In specialization we can, 

Select correct option:

  1. Replace child class with its base class
  2. Replace base class with its child class (Not Sure) 
  3. Replace both child and base classes interchangeably
  4. None of the given options

 

 

Consider the code below, class class1{ public: void func1(); }; class class2 : public class1 { }; Function func1 of class1 is ____ in class2,
Select correct option:

  1. public 
  2. protected
  3. private
  4. none of the given options

 

 

It is illegal to make objects of one class members of another class.
Select correct option:

  1. True 
  2. False

 

 

An abstract class is useful when
Select correct option:

  1. no classes should be derived from it.
  2. there are multiple paths from one derived class to another. 
  3. no objects should be instantiated from its.
  4. you want to defer the declaration of the class.

 

 

In resolution order compiler search firstly _______.
Select correct option:

  1. Generic Template
  2. Partial Specialization
  3. Complete Specialization
  4. Ordinary function

 

 

 

template<> class Vector{ void** p; //…. void*& operator[] ((int i); };
Select correct option:

  1. This specialization can then be used as the common implimentation for all Vectors of pointers.
  2. This spcialization can then be used as the all type implimentation for one type classes.
  3. This specialization can then be used double type pointers.
  4. This specialization should be used for Vectors of all type int types.

 

 

 

In private inheritance derived class pointer can be assigned to base class pointer in,
Select correct option:

  1. Main function
  2. In derived class member and friend functions
  3. In base class member and friend functions
  4. None of the given options

 

 

Which statement will be true for concrete class?

  1. it implements an virtual concept.
  2. it can be instantiated 
  3. it cannot be instantiated
  4. none of given

 

 

Target of a _____ function call is determined at run time.
Select correct option:

  1. instance
  2. virtual 
  3. operator
  4. none of given

 

 

The Specialization pattern after the name says that this specialization is to be used for every___.
Select correct option:

  1. data types
  2. meta types
  3. virtual types
  4. pointers type

 

 

c++ dynamic binding and polymorphism will be achieved when member function will be __.
Select correct option:

  1. private
  2. public
  3. virtual 
  4. inline

 

 

Consider the code below, class class1{ protected: void func1(); }; class class2 : public class1 { }; Function func1 of class1 is ____ in class2,
Select correct option:

  1. public
  2. protected
  3. private
  4. none of the given options

 

 

Consider the code below, class class1{ protected: int i; }; class class2 : protected class1 { }; Then int member i of class1 is ____ in class2,
Select correct option:

  1. public
  2. protected
  3. private 
  4. none of the given options

 

 

Consider the code below, class class1{ private: void func1(); }; class class2 : private class1 { }; Function func1 of class1 is ____ in class2,
Select correct option:

  1. public
  2. protected
  3. private
  4. none of the given options

 

 

Target of a _____ function call is determined at run time.
Select correct option:

  1. instance
  2. virtual 
  3. operator
  4. none of given

 

 

Consider the following statements: 1) int iArray[5]; 2) int *pArr = iArray;
Select correct option:

  1. These statements will compile successfully
  2. Error in first statement
  3. Error in second statement 
  4. None of given options

 

 

Consider the code below, class class1{ private: int i; }; class class2 : private class1 { }; Then int member i of class1 is____ in class2,
Select correct option:

  1. public
  2. protected
  3. private
  4. none of the given options

 

 

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.
Select correct option:

  1. base 
  2. derived
  3. virtual
  4. implemented

 

 

A class template may inherit from another class template.
Select correct option:

  1. True 
  2. False

 

 

Derived class can inherit from public base class as well as private and protected base classes
Select correct option:

  1. True
  2. False

 

 

Two functions with same names, parameters and return type can exist in,
Select correct option:

  1. Function overloading 
  2. Function overriding
  3. Operator overloading
  4. None of these options

 

 

Consider the code below, class class1{ private: int i; }; class class2 : public class1 { }; Then int member i of class1 is____ in class2,
Select correct option:

  1. public
  2. protected
  3. private
  4. none of the given options

 

 

Target of a _____ function call is determined at run time.
Select correct option:

  1. instance
  2. virtual 
  3. operator
  4. none of given

 

 A class template may inherit from another class template. 

Select correct option:

  1. True 
  2. False

 

 

A function call is resolved at run-time in_________
Select correct option:

  1. non-virtual member function
  2. virtual member function
  3. Both non-virtual member and virtual member function. 
  4. None of given

 

 

A class hierarchy
Select correct option:

  1. shows the same relationships as an organization chart.
  2. describes “has a” relationships.
  3. describes “is a kind of” relationships. 
  4. shows the same relationships as a family tree.

 

 

Consider the code below, class class1{ public: int i; }; class class2 : public class1 { }; Then int member i of class1 is____ in class2,
Select correct option:

  1. public 
  2. protected
  3. private
  4. none of the given options

 

 

Consider the code below, class c1{ }; class c2 : public c1 { }; class c3 : public c2 { }; Then c1 is,
Select correct option:

  1. Direct base class of c3
  2. Direct child class of c3
  3. Direct base class of c2
  4. Direct child class of c2

 

 

A class can inherit from more then one class is called.
Select correct option:

  1. Simple inheritance
  2. Multiple inheritances
  3. Single inheritance
  4. Double inheritance

 

Check Also

CS304 Unsolved Final Term Paper Spring 2010

Question No: 1    ( Marks: 1 )    – Please choose one  Classes like TwoDimensionalShape and …

2 comments

  1. These are really helpful for me tomorrow my cs304 paper held at 11.00 plz pray for my paper.

Leave a Reply

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

*