PRE GTU SEMESTER EXAM V.V.P. ENGINEERING COLLEGE, RAJKOT B.E. IV SEM (CE) SUB: Object Oriented Programming with C++ (2140705)
DATE: Q-1 a. b. c. d. e. Q-2 a. b. c.
d.
e. Q-3 a. b. c. d. e. Q-4 a.
TOTAL MARKS:70 Define OOP with its benefits. Differentiate between OOP & POP. Explain basic concepts of Object-Oriented Programming. (features of oop) 1. What is Reference variable? What is its major use? Give Example. 2. Explain Memory Management Operators in detail. Explain enum and Scope Resolution Operator in detail. Explain Function Overloading and Inline function with the help of suitable example. What is the purpose of Static? Write Characteristics of Static Data Member & Static Member Function. Write a program that demonstrates the Static Data Member & Static Member Function. Define a class Distance with real and imaginary as two data , add necessary member functions to initialize and display data of class. Define a member function sum() which adds two Distance objects. Invoke the statements like D3.sum (D1, D2) in main(). Create a class Product with Product Name, Product Code and Product Cost as three data . Define functions to assign and display value. Define function that search a given Product based on Code given by the . If Product exists, print the detail of that Product. Write a program using arrays of object. Declare at least 10 Products. Explain Friend function. Also state its characteristics. Create a class Polar which describes a point in the plane using polar coordinates: radius and angle. Create another class Rectangular which describes a point in the plane using Cartesian coordinates: x and y. Write a program that can read values for the class objects and add one object of Polar with another object of Rectangular. Use a friend function to carry out the addition operation. The object stores the results may a Polar object or Rectangular object, depending on the units in which the results are required. Radius = sqrt (x*x + y*y) Angle = atan(y/x) x = Radius * cos(Angle) y = Radius * sin(Angle) Create a class Complex to store complex number. Overload (+) operator to add two complex numbers using friend function method. What is a constructor? Which are the special characteristics of constructor functions? Explain parameterise constructor with example. What is destructor? What is the significance of using it in a program? Explain the use of destructor using a suitable program. What is type conversion? Explain one class type to another type class conversion with a suitable example. What is operator overloading? Write a program to overload binary plus (+) and (>=) operator to add and compare two strings. What is Inheritance? Explain Multiple Inheritance in detail. Consider a class network as shown in figure given below. The class Employee derives information from both and classes which in turn derive information from the class Person. Define all the four classes and write a program to create, update and display the information contained in Employee objects.
[7] [7] [4] [3] [7] [7] [7] [7] [7]
[7]
[7] [7] [7] [7] [7] [7] [7]
b. c.
d. e. Q-5 a. b. c. d. e.
Differentiate between method overloading and overriding with a suitable example. 1. Explain this Pointer. 2. Write a program that handles the following exceptions: Divide-by-zero Square-root of negative number What is Exception? Write a program that demonstrates use of catching all exceptions. What is Polymorphism? Explain Run-Time Polymorphism in detail. Explain file pointers and functions for their manipulations. Create a class Template Array to create and display array of 5 elements. Write a program that uses function templates for implementing the bubble sort algorithm. Write a program, which returns size of the file in bytes. Explain different file mode parameter for open() with example. Write output for the following (Assume all libraries have been included): 1. int main() { float f = -76.54321; cout.fill (‘*’); cout.precision(3); cout.setf(ios::internal, ios::adjustfield); cout.setf(ios::scientific, ios::floatfield); cout.width(15); cout << f << “\n”; } 2. int main() { float f = 123.4; cout.setf(ios::showpoint); cout.setf(ios::showpos); cout.precision(3); cout.setf(ios::fixed, ios::floatfield); cout.setf(ios::internal, ios::adjustfield); cout.width(10); cout << f << “\n”; }
[7] [3] [4] [7] [7] [7] [7] [7] [7] [3] [4]