0% found this document useful (0 votes)
8 views2 pages

UTA018

Uploaded by

dpatelbe22
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views2 pages

UTA018

Uploaded by

dpatelbe22
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Roll Number: Group-Subgroup:

Thapar Institute of Engineering & Technology, Patiala


Department of Compute, science & Engineering
B.E./ B.Tech. - (II Semester) UTA018: Object Oriented Programming
MST : March, 13, 2019 ; 13 :00 — 15:00
Time: 02 Hours; MM: 25 Name of Faculty: Dr. Seema Bawa, Dr. Vinay Arora,
Dr. Palika Chopra, Dr. Raman Goyal, Dr. Ravi
Prakash, Dr. Hemant Gianey, Dr. Smita Agarwal, Mr.
Gurpal Chhabra, Mr. Vaibhav Agarwal

NOTE: Attempt ALL questions. It is COMPULSORY to write your GROUP Name (with
SUBGROUP No) (like A2, 13, E5, P4 etc.) at the top of the answer sheet(s).

Q 1. a) Define a class and explain its role by creating suitable object(s) of the class. (2)
b) Differentiate between dot member selection operator and arrow member selection operator, with
suitable example(s). (2)
c) Can we pass object(s) as arguments to (i) member functions? (ii) non member functions? Give
examples supporting your answers. (2)

Q2. a) What is scope resolution operator? Explain its three different usages with example for each. (1,3)
b) What is the output of the following code? (2)

#include<iostream>
using namespace std;
int main()
{
int x;
int *p:
int *q;
p=new int(10];
c1=1);
*p=4;
for (int j=0;j<10;j++)

for int k=0;k<10;k++)


{
11 ;
cout<<*q
q++;
}
cout<cendl;
return 0;

Q3. a) Define multiple inheritance. What is the crder of calling the constructor(s) and destructor(s) in
multiple inheritance? Explain with the help of suitablc example.
b) What is the need of access specifier "protected" in C-ffF?
c) Write the output for following codes with appropriate explanations.

Best wishes Page 1/2


W #incluctream>
using namespace std;
class Base
{
protected:
int a;
public:
Base ()
{ a=9; }
void display()
{
cout«"The output is"<<a;
}
};
class Derivedi: public Base
{
public:
Derived1{)
{ a=12; }
};
int main()
{
Derivedl ob;
ob.display();

(ii) #i nclud,,,:,,treAm›
using namespace std;

void poly(float a, float h)


{
cout <c - Function with float values called ";
}

void poly(int r, int s )


{
cout << "Function with integer values called ";
)
int main()
{
poly(7.S,9.7);
)

Q4. a) Write a program in C++ to calculate the total number of objects created in a program.
[Suggestions: Take the name of class as "test"; Use Constructor to increment the count of objects
created; create three objects in main function; display count using showCount() method once after the
creation of 2nd object and next after the 3rd object.] (2)

b) Explain the following terms with suitable examples:


i) Inline function ii) friend function
iii) this pointer iv) Copy constructor
v) Nested function (lx5)

Best wishes Page 2/2

You might also like