Question 1: Explain the term Class and Object using the example of a student class. The student class represents name, enrolment number, father’s name, telephone number, programme code and date of birth of a student. The class has a function to show the information about the student except date of birth, and to modify the information of telephone number and programme. List the private and public members (data members as well as member functions) for the class student. Define the data types of member variables using C++ and create few objects of the class. Can you put information in those objects? Give reasons. (8 Marks)
Question 2: Explain the following terms in the context of object oriented programming using the student class of question 1. You must use C++ to define the student class. In addition, assume that the student class has a sub class namely “PhD Student” who has an additional field “Department”. The function to show the information about PhD student also prints the department in addition to showing the information as shown by the student class. (28 Marks)
(a) Overloaded Constructors
(b) Encapsulation
(c) Inheritance
(d) Polymorphism
Question 3: What are the advantages of using UML? Create the class diagram for a University having classes – Student, Teacher, Subject and Programme. Make suitable assumptions, if any. (8 Marks)
Question 4: Explain the usage of the following C++ operators with the help of an example program. (8 Marks)
(a) operator for type casting
(b) operator for bitwise OR
(c) operator for dereferencing an address
(d) comma operator
Question 5: Differentiate between call by value and call by reference with the help of an example in the content of function call. Explain the advantages of call by value. What does C++ uses? (8 Marks)
Question 6: Write a template class “binaryTree” in C++. The class should have functions for search and insert and element into a binaryTree. Use this template to create a binary tree of integer keys. Make suitable assumptions, if any. (20 Marks)
Question 7: Create a class AlphaString that stores only alphabets in a string of arbitrary length. The string has a constructor that makes sure that String has only Alphabets. The class also has a copy constructor, and an overloaded + operator. The overloaded + operator should perform the concatenation of two strings. Does the class need an explicit destructor? Justify your answer. (20 Marks)

Recent Comments