CS304FinalTermSolved_Subjective_byVirtualians.pdf

Verified academic study resource for CS304 (Object Oriented Programming) under the Computer Science at Virtual University of Pakistan. This PDF document (Final-Term Solved Past Paper & Examination Pack) covers Final-Term Exam Scope (Lectures 23 to 45) spanning approximately 320 pages across 4 curriculum modules, and is indexed for student examination review with instant in-browser preview and 100% free direct download.

Course
CS304 – Object Oriented Programming
Faculty
Computer Science
Format
PDF
Type
Final-Term
Coverage
Final-Term Exam Scope (Lectures 23 to 45)

Virtual University regulations strictly require achieving at least 20% marks in the Final-Term exam paper alone (typically 12+ marks out of 60) to pass CS304, regardless of midterm scores.

What this file covers — CS304 syllabus roadmap

  1. Object-Oriented Paradigms: Classes & Data Abstraction — Lectures 23 to 29 (Pages 281 to 360). 16% Final-Term Marks (Core OO Concepts)
  2. Inheritance Hierarchies & Dynamic Polymorphism — Lectures 30 to 36 (Pages 361 to 435). 20% Final-Term Marks (Virtual Functions & V-Tables)
  3. Templates, Standard Library & Persistent File I/O — Lectures 37 to 41 (Pages 436 to 510). 14% Final-Term Marks (Generic Code & Streams)
  4. Final-Term Examination Dossier & Capstone Synthesis — Lectures 42 to 45 (Pages 511 to 585). Final-Term Exam Synthesis (Lectures 23–45 Scope)

Frequently asked questions

Where can I download CS304FinalTermSolved_Subjective_byVirtualians.pdf for free?

You can preview and download "CS304FinalTermSolved_Subjective_byVirtualians.pdf" (CS304 PDF, ~320 pages) directly from the MIHORA VU Study Library (https://study.mihora.tech/doc/cs304finaltermsolved-subjective-byvirtualians-pdf) with 100% free high-speed downloads and zero registration requirements.

What syllabus chapters and lectures are covered in this CS304 file?

This document covers Final-Term Exam Scope (Lectures 23 to 45) across 4 distinct lecture units (Lectures 23 to 29, Lectures 30 to 36, Lectures 37 to 41, Lectures 42 to 45), featuring comprehensive definitions, solved objective questions, and examiner marking rubrics.

What is the passing criteria for CS304 under the VU 20% Two-Half Rule?

Under official Virtual University regulations, students must score at least 20% in the First Half (Quizzes, Assignments, GDBs, and Midterm combined) AND independently at least 20% in the Final-Term examination paper. Scoring under 20% in the final exam results in an automatic F grade regardless of earlier marks.

Are CS304 solved past papers and handouts verified for 2026 exams?

Yes. All CS304 materials on MIHORA VU—including Moaaz, Waqar Siddhu, and team archives—are reviewed against the current VU syllabus to help students prepare for 2026 Midterm, Final-Term, and online quiz examinations.

Inside this file

           CS304-Object Oriented programming NEW Solved Final terms papers with

                    references from 2012-2013 by Virtualians.pk

Q) Describe the way to declare a template function as a friend of any class?(2marks)

Answer:- (Page 294)

      Template<class U>

      Void doSomething (U);

      Template<class V>;

      Class A{

       int data;

      };

Template<class T>

      Class B{

            int data;

      friend void doSomething(T);

      friend A<T>;

Prepared By: Irfan Khan (chief Admin)                                             Page 1

      };

Q) Give the C++ code of template function to print the values of any type of array I
int.this function will take 2 parameters one will be pointer and other will be will be
size of array (mrk3)

Answer:- (Page 257)

      Template<class T>

      Void printArray(T*array,int size)

      {

      For(int i=0;i<size;i++)

      Cout<<array[i];

       int main()

      int iArray[5]={1,2,3,4,5};

      void printArray(iArray,5);

      return 0;

      }

Prepared By: Irfan Khan (chief Admin)                                            Page 2

       Q) Consider the code below,

         1. template<typename T> class Test {
         2. T value;
         3. public:

         1. Test( T val ) : value(val){}

         1. Test(const Test<T>& c) : value(c.value) {}

         1. };

         1. int main() {
         2. Test< int > t1( 0 ), t2( 0 );
         3. Test< float > t3 = t1;
         4. system("PAUSE");
         5. return 0;
         6. }

Q) Give line number having any error/errors in this code explain the reason for
error/s and give corrected code as well.
       Answer:
       Test< float > t3 = t1;
       There is an error in this line due to conversion from int to float but in a wrong way

Q) Why Abstract class’s objects cannot be instantiated?
      Answer:- (Page 230)
     Abstract class’s objects cannot be instantiated they are used for inheriting interface
     or implementation so that derived classes can give implementation of these
     concepts.

Prepared By: Irfan Khan (chief Admin)                                                 Page 3

      Q) What output is produced by the following code?

      int wait_time=46;
      try
      {
      cout “Try-block entered.\n”;
             if (wait_time > 30)
                throw wait_time;
             cout ”Leaving try-block.\n”;
      }

      catch ( int thrown_value)
      {
      cout “Exception thrown with\n””wait_time equal to “thrown_valueendl;
      }

      cout “After catch-block” endl;

Q) Write C++ code for the overloaded subscript operator of following template
Vector class.

Answer:

      template< class T >

      class Vector {

      private:

             T* ptr;

Prepared By: Irfan Khan (chief Admin)                                       Page 4

                int size;

                 int index;

       public:

              T& operator [](int); // overloaded subscript operator
       };

Q) What do you mean by Stack unwinding?

Answer: - pg 336

The flow control (the order in which code statements and function calls are made)as a
result of throw statement is referred as “stack unwinding”

It takes place in two ways.

Q) Write general syntax of nested try catch block?
     Answer:- pg 344

int main()

{

try{

       try{

       throw 1;
Prepared By: Irfan Khan (chief Admin)                                              Page 5

       }

       catch (float) {}

       }

       catch(int){

       }

       return 0;

       }

Q ( Marks: 3 ) Consider the code below, template< typename T > class T1 { public:
T i; protected: T j; private: T k; friend void Test(); }; This code has a template class
T1 with three members i,j and k and a friend function Test(), you have to describe
which member/s of T1 will be available in function Test().

Answer:- All of them (i, j, k) will be available in function Test().

Q) In which situation do we need to implement Virtual inheritance?
Explain with an example (5 marks)

Answer:-
In multiple inheritance while solving diamond problem virtual inheritance need to
implement. The solution of avoid this problem is virtual inheritance so that in multiple
inheritance only one copy of base class is generated as shown below instead of two

Prepared By: Irfan Khan (chief Admin)                                                Page 6

separate copies. In virtual inheritance there is exactly one copy of the anonymous base
class object
       class Vehicle{
       protected:
       int weight;
       };
       class LandVehicle :
       public virtual Vehicle{
       };
       class WaterVehicle :
       public virtual Vehicle{
       };
       Example
       class AmphibiousVehicle:
       public LandVehicle,
       public WaterVehicle{
       public:
       AmphibiousVehicle(){
       weight = 10;
       }
                                      2mark Questions:

Q) Write down a list of four intangible objects?

Answer (page no 13)

   •   Hours
   •   Seconds
   •   Minutes
   •   Year
   •   Month

Prepared By: Irfan Khan (chief Admin)                                               Page 7

Q) Write three important features of virtual functions?

Answer (page no230)

1) Virtual function achieve exactly same kind of functionality that can be achieved by
complex code of switch statement

2) Target class of a virtual function call is determined at run-time automatically

3) In C++ we declare a function virtual by preceding the function header with keyword
“virtual”

Q) Give the C++ code of template function to print the values of any type of array I
int. This function will take 2 parameters one will be pointer and other will be will
be size of array?

Repeated

                                  3 mark Questions:

Q) Describe the salient feature of abstract class?
Answer (page no 36)
They are present at or near the top in the class hierarchy to present most generalized
behavior

Main purpose is to be inherited by other classes
Cannot be instantiated
Promotes reuse

More CS304 files

All CS304 files · Midterm Prep 2026 · MCQs Bank