Latest Activity In Study Groups

Join Your Study Groups

VU Past Papers, MCQs and More

We non-commercial site working hard since 2009 to facilitate learning Read More. We can't keep up without your support. Donate.

0zuhg2li6sifq

Please Share you Current Final Paper of CS304 Object Oriented Programming (20 July 2013 TO 31 July 2013)

Please Share you Current Final Paper of CS304 Object Oriented Programming (20 July 2013 TO 31 July 2013)

Views: 3016

Replies to This Discussion

if midterm=24 =24/40=.60 then .60*35=21 marks

gdb=3.750

assignments=37=37/100=.37 then .37*12=4.44

quiz=8+2+2=10  10/30=.3333  then .3333*3=.9999

all total=21+3.75+4.44+0.999= 30

Know required for final term for pass marks

iF HE OBTAINED 21/80 THEN he will pass as

21/80=0.26 then 0.26*45=11.81

total he obtains is

30+11.81=41.81

I think that ab sb ko samj ah jani chaye

thanks Mr. Riaz SB

1.  Describe the way to declare a template class as a friend class of any other class? 2 marks

Class A{

};

Template<class T>

Class B{

Friend A;

};

 

2. Describe the way to declare a template class as friend of other template class. 2 marks

Template<class T>

Class A{

Friend class B;

};

Template <class T>{

Friend class B;

};
3. Give the name of two basic types of containers collectively called first class container?? 2 marks

Sequence and associative containers are called first class containers. For example dequeue and lists are sequence containers while set and multiset are associative containers.

4. Show that OO model deals with the same entities /objects as they exist in a particular domain or in a particular real situation word use example of Ali derives a car?? 2 marks 

5. In which situation we should use operator overloading and in which situation we should use Templates??2 marks 

Function templates are used when we want to have the exactly identical and same operations on different data types. In function templates we can not change the implementation from data type to data type. For particular data types we implement specially.

If we want similar operations on different data types we use function overloading.

 
6. Write a Template Function that takes one Template parameter and always returns value that is equal to double of its parameter  value ( Parameter *2)???? 3 marks 

Template<class T>

Double fun(T x){

Return 2*x;

}

Main()

{

Fun(5);

}


7. Write Down The Advantages of Constructor and destructors in respect of class with no dynamic data members? 3 marks

 In oop constructors are used to initialize class data members with corresponding values, and destrutors are used  for opposite functionality of the constructors such as to deallocate the memory after of its usage. The provide facility to escape from existence of unexpected  value in data members.  If no dynamic memory allocated in our classes then constructor provides the default behavior. We are not in trouble of allocating the memory and returning it to heap. Because in dynamic allocation its progamer responsibility to free that allocated memory explicitly.  

8. Give the general syntax Of nested try catch blocks?? 3 marks 
try{

            Try{

            }cath(exception x){

         }

 }catch(exception x){

}


9. Write C++ code to overload the subscript[] operator for string class?? 5 marks 

class string{

Public: char &operator[](int);

};

Char & String::operator[](int pos)

{

Assert(pos>0 && pos<=size;);

Return sptr[pos-1];

}

 

10. Write a template function that returns the average of all the elements of an array the argument to the function should be the array name and the size of array type (Type int)? 5 marks 

Template<typename T, SizeT size>

float average(array<T,  size>&a){

float total=0.0;

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

total+=a.[i];sy

Return temp;

11. Write the C++ code for the overloading subscript operator of following template vectors ??5marks

Class string{

Public:

Char &operator[](int);

};

Char & string::operator[](int pos){

Assert(pos>0 && pos<=size);

Return sptr[pos-1];

}

 

  1. wht do you mean by stack unwinding?
    In programming to resolve errors and exceptions using exception handling technique. That uses two blocks try and catch or more then two blocks in nesting. Stack unwinding is the flow control as a result of throw statement is referred as stack unwinding. It is take place in two ways.
  2. using try and catch blocks.
  3. Using nested functions

Void f1(){

                    Throw exception();

}

Void f2(){

              F1();

}

Main()

{

Try{

F2();

}

Catch(exception)

{

}

Return 0;

}

 

  1.  Give the general sentex of nested try catch blocks.

Try{

              Try{

             

              }

Catch( exception x){

}

}catch(exception x){

}


3. Sensitive comparison of two strings.

int CaseSenstive(char *s1, char * s2)

{

For(int i=0;i< strlen(s1) && i<strlen(s2); ++i)

If(s1[i]!=s2[i])

Return s1[i]-s2[i];

Return strlen(s1)-strlen(s2);

}


4.  State any conflict that may arise due to multiple inheritances.

Increased complexity

Reduced understanding

Duplicate features

             Ambiguity

             Diamond problem


5. Real world multiple inheritance understanding example.

Class Fruit{

Char color;

Public:

setColor();

getColor();

 

}

Class apple: public fruit{

}

Class orange: public fruit{

}

Mermaid and fish

Vehicle land vehicle and water vehicle amphibious vehicle

Grandparents parents and children’s


6. Give code of template funtion to print the value of any typ of array.

 

 

today cs304 current paper total 52 question 40 mcq and 12 question mcq mostly from past paper also subjective.

1) give name of two templates?

Function templates and class templates.
2)give one advantage and one dis advantage of templates?

Advantages:                                                                 Disadvantages

Reusability                                                                       consume memory

Write ability                                                                     incorrect results in some cases

Maintainability                                                                  


3)name of any two error handling technique?

Abnormal termination

Graceful termination

Return illegal value

Return error code form a function

Exception handling

 

4)Give code of template funtion to print the value of any type of array.

 

My today's paper

mcq's from past paper

q1: what do you mean by stack unwinding?

q2: Give the general syntax of nested try catch blocks.

q3 function template explain briefly

Templates are the part of generic programming. They provide facility to use same code for different data types. In c++ there are two kinds of templates. A class template and function template. A function template can be parameterized to operate on different types of data types. We write template keyword to make function template as class templates. Its syntax is following here:

 

Template<class T>

Void fName(T x); or

 

template<typename T>

void fName(T  x);

 

template<class T, class U>

void fName(T x, U y);

 

q4: abnormal termination function code in c++

 

void getNum(int &x, int &y){

cout”\nEnter two integers: “;

cin>>x>>y;

}

int getQuotient(int x, int y){

return x/y;

}

void display(int x, int y, int q){

cout”\nQuotient of “x” and “y” is : “q;

}

int main()

{

Int sum=0, q;

Int x,y;

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

{

getNumber(x,y);

q=getQuotient(x,y);

sum+=q;

display(x,y,q);

}

Cout”Sum of 5 quotients is :  “sum;

Return 0;

}


Total Questions: 52

 

Total Marks: 80

2 mark Questions:

1. Write down a list of four intangible objects?

Time hours seconds minutes, year date month,  

2. Describe three properties necessary a container to implement generic algorithms.

 

3. Write three important features of virtual functions

They are use to inherit interface and implementation of class. Pure virtual functions inherits only interface and normal virtual functions inherit both interface and implementation of the base class. They provide the facility of polymorphism. V-tables of virtual functions make the programs slow due to involvement of extra pointer manipulation.

 

Q:1: 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.

q.2. Give the pseudo code of non case sensitive comparison function of string class.

Answer:

int caseSencompare( char* str1, char* str2 ) { for (int i = 0; i < strlen( str1 ) && i < strlen( str2 ); ++i) if ( str1[i] != str2[i] ) return str1[i] - str2[i]; return strlen(str1) - strlen(str2);

q.3 What are the container requirements?

q.4. 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 (mrk5)

Answer:- (Page 257) template< typename T > void printArray( T* array, int size ) { for ( int i = 0; i < size; i++ ) cout array[ i ] “, ”; // here data type of array is T } Give the name of three

q.5Give the name of three operation that a corsor or itrator generally provide (mrk3)

Answer:-

 •T* first() • T* beyond() • T* next( T* )

q.6what are container classes? How many types of container classes are there?

Answer:-

 Container is an object that contains a collection of data elements like we have studied before now we will study them in detail. STL provides three kinds of containers, 1. Sequence Containers 2. Associative Containers 3. Container Adapters

past paper me sey muje sara paper aya

baki jo program aye wo yaad nai ap past paper waly ur try wale program lazmi kren

Thank you!

RSS

© 2021   Created by + M.Tariq Malik.   Powered by

Promote Us  |  Report an Issue  |  Privacy Policy  |  Terms of Service