3rd Semester, B. Tech, Object Oriented Programming, IT 2005 (For 2022 (L.E.) 2021 & Previous Admit
3rd Semester, B. Tech, Object Oriented Programming, IT 2005 (For 2022 (L.E.) 2021 & Previous Admit
SECTION-A
I. Answer the following questions. [ I x 1 O]
(a) How does a class enforce data-hiding, abstraction &
encapsulation?
(b) Illustrate the concept of default arguments using appropriate
example.
(c) Differentiate between function overloading and function
overriding.
(d) What do you mean by virtual base class?
(e) In an overloaded binary operator function, why does friend
function take two objects and whereas member function takes
just one object?
(f) What is delegation?
(g) Find the output.
#include <iostream>
using namespace std;
class A
{
int a;
public:
A(){}
void show_A()
{ cout<<a<<endl;
}
};
class B{
int b;
public:
B(){}
B(int d)
{b=d; }
-BO
cout<<"Object of B being deleted"<<endl;
}
void show B()
{ cout<<b<<endl;}
};
class C: public A, public B
{
int c;
public:
C():A(),B(){}
C(int dl, int d2,int d3):A(d1),B(d2)
{
c= d3;
}
-co
{
cout<<"Object of C being deleted"<<endl;
}
void show_CO
{
show_A();
show_B();
cout<<c<<endl;
}
};
6. (a) Write a program to copy the contents of one file in reverse order [4]
to another file.
(b) Convert Centimeter to Meter using class type to basic type [4]
conversion.( 1Meter = 100 Centimeter)
SECTION-D
7. (a) Write a program in C++ to enter a string into file and read the [4]
same file to display all the words in the file with starting letter
'R'.
(b) Convert Degree to Radian using conversion routine in the [4]
destination class. (Radian=Degree* PI /180)
8. (a) Write a C++ program to implement the following structure: [4]
Create a class Person with data members: name & age &
member functions: void readdata() & void displaydata(). Derive
a class Student from the class Person with data members: Roll
No & Branch & member functions: void readdata() & void
displaydata(). Derive a class Exam from the class Student with
data members: mark! & mark2 & member functions: void
readdata() & void displaydata(). Derive a class Sports from the
class Person with data members: game_name & score &
member functions: void readdata() & void displaydata(). Derive
a class Result from the class Exam & the class Sports with data
member: total & member functions : void readdata() & void
displaydata(). Result class will display the total marks scored
by the student by adding the subject marks and score.
(b) Write a C++ program for overloaded template functions to [4]
calculate the perimeter of a circle, square and rectangle.
*****