Skip to content
VUBuddy

CS304 Final Term Solved Subjective with References by Moaaz

Object Oriented Programming PDF 245 KBUpdated 23 Oct 2026
Final term past paper CS304 Final Term Solved Subjective with References by Moaaz PDF 245 KB
vubuddy.com
Type
Final term past paper
Course
CS304 Object Oriented Programming
Size
PDF 245 KB
Updated
23 Oct 2026
Free download 0 of 3 used today
Download free · 245 KB

You get 3 free files a day on the website. Add the Chrome extension for 30 a day.

Unlimited downloads in the Android app Get it free on Google Play

Preview text

Text from pages 1, 2, 3 of 26. Download the file for all 26 pages.

CS304- Object Oriented Programming · LATEST SOLVED SUBJECTIVES · FROM FINALTERM PAPERS · FEB 16,2012 · Subjective solved

Q42. Write the names of two types of Templates. MARKS: 2

Answer: (Page 256) a. Function Templates (in case we want to write general function like printArray) b. Class Templates (in case we want to write general class like Array class)

Q42. Describe the way to declare a template function as a friend of any class. 2marks

Answer: (Page 294)

template< class T >

class B { int data; friend void doSomething( T ); // granting friendship to template doSomething in // class B friend A< T >; // granting friendship to class A in class B

Q43. Can a constructor throw an exception? How to handle the errors, when the constructor fails?

Answer: Yes, Constructor can throw an exception But In constructor if an exception is thrown than all objects created so far are destroyed. Exception due to constructor of any contained object or the constructor of a parent class can be caught in the member initialization list.

Q44. Why these operators can not be overloaded:

Answer: (Page 141) Reason: They take actual current object name, rather than value in their argument

Q46. What is graceful termination method of Error handling; give its example using C++.

Answer: (Page 330) Program can be designed in such a way that instead of abnormal termination, that causes the wastage of resources, program performs clean up tasks, mean we add check for expected errors (using if conditions), Example – Graceful Termination int Quotient (int a, int b ) { if(b == 0){ cout << “Denominator can’t “ << “ be zero” << endl; // Do local clean up exit(1);

return a / b;

Q47. How can you describe Virtual destructor? Why Virtual destructor is used?

Answer: (Page 234) When delete operator is applied to a base class pointer, base class destructor is called regardless of the object type. Only base class part of object will be deleted other parts will remain as it is this result in memory leak (wastage of memory), Virtual Destructors make it possible that complete object is being deleted so there is no memory leak (waste of memory).

Q48. Motor car can be called a good candidate for being an object so, this ibject contains Encapsulation characteristic. You are required to apply the concept of Encapsulation on “Motor Car”.

Answer: Yes Motor Care is a good candidate for apply the concept of encapsulation In Motor Car we have the following Objects which fully describes the phenomena of encapsulation.

  1. Steer Wheels
  2. Accelerate
  3. Change Gear
  4. Apply Brakes
  5. Turn Lights On/Off

In encapsulation we just provide the user an interface and hide the Full implementation from the user because user don’t want to know the implementation he Just want his work should be done perfectly

For example: Breaks of car, we gave just a paddle to the User and encapsulate how it works inside the engine. Same for accelerator, gear, steer wheels and turn on and off of Light.

Q49. Suppose base class and derived class has a member function with same signature. Now call that member function through the pointers to a base class object. Now, what determines that the base class member function or derived class function will be called?

Q51. What do you know about exception in initialization? Explain with example.

Answer: (Page 345)

Exception due to constructor of any contained object or the constructor of a parent class can be caught in the member initialization list.

Example

Student::Student (String aName) : name(aName) /*The constructor of String can throw a exception*/

The programmer may want to catch the exception and perform some action to rectify the problem

Example

Student::Student (String aName) try : name(aName) {

catch (…) {

Q1. How can we set the default values for non type parameters?

Answer: (Page 284) We can set default value for this non type parameters, as we do for parameters passed in ordinary functions, template< class T, int SIZE = 10 > class Array { private: T ptr[SIZE]; public: void doSomething();

2. Explain the statement vector <int> ivec (4,3)

Answer: This would create a vector of four elements, each one initialized to 3. ivec looks like this:

  1. Tell the procedure of making a class abstract in C++ by giving an example.

Answer: (Page 230)

virtual function is a concrete class (which object can be instantiated)

A class having pure virtual function(s) becomes abstract

All CS304 files →
CS304 Object Oriented Programming All CS304 handouts, past papers, quizzes and MCQs in one place. Open course page

Get more out of VUBuddy, for free

Android app Free on Google Play
  • Unlimited downloads
  • The explanation behind every MCQ answer
  • Study offline on slow data
Get the Android app
Chrome extension Free on the Chrome Web Store
  • 30 downloads a day instead of 3
  • Sign in and buy Pro Semester here
Add to Chrome

One Pro Semester membership works in both the extension and the app.