Q.1. (a) What is dynamism in the context of the object oriented programming paradigm ? What are the different types of dynamism existing in the object-oriented programming paradigm.? Explain each type with the help of an example.
(b) For each of the statements labelled (i), (ii),( iii) and (iv), point out the errors, if any. If there is no error in a statement, indicate its effect.
Class base
{
int i;
public :
void set_i(int num) {i=num;}
int get_i( ) {return i;}
}
Class derived : public base
{
int j;
public :
void set_j(int num) (j=num;)
int get_j( ) {return j;}
}
void main ()
{
base *bp;
derived d;
bp = &d;
bp --> set_i(10); (i)
bp --> set_j(20); (ii)
cout << bp -->get_i(); (iii)
cout << bp --> get_j(); (iv)
}(c) What is inheritance ? What are its advantages ? Explain any two
types of inheritance with the help of an exemplar diagram.
(d) What is UML ? What are the benefits of UML for system designers ? List four types of UML diagrams.
(e) Design a template class that is used to create a doubly linked list of integers or floats. Implement 'insert' and 'delete' operations along with the printing of elements. Also, check whether the linked list is null or not.
Q.2. Design and implement a class 'string' using an array, with a maximum size of 20 characters. The class should contain the necessary constructors, destructor, overloaded assignment operator and a friend function for concatenation of two strings. Make suitable assumptions if required. Also write main( ) for the above.
Q.3. (a) What is the need of a virtual function ? Describe this with the help of a suitable example using C++. What is a pure virtual function ?
(b) What is an inline function ? In which situations would you make a function inline ? Give two examples of inline functions.
Q.4. Design and implement a class 'stack' using pointers. The class should include necessary constructors and destructor and the functions for addition and deletion of elements. It should also check whether a stack is full or empty. Make any assumption, if required.