0% found this document useful (0 votes)
59 views3 pages

Oops April 2017 Set 1

This document contains instructions and questions for an Object Oriented Programming exam using C++. It covers topics such as friend functions, new and delete operators, classes and objects, access specifiers, memory leaks, copy constructors, multiple inheritance, virtual functions, file I/O, polymorphism, and accessing class members. The exam consists of 5 sections with 3 questions each, worth a total of 50 marks. Students are required to answer all questions, which involve explaining concepts, writing code examples, and analyzing/correcting code samples.

Uploaded by

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

Oops April 2017 Set 1

This document contains instructions and questions for an Object Oriented Programming exam using C++. It covers topics such as friend functions, new and delete operators, classes and objects, access specifiers, memory leaks, copy constructors, multiple inheritance, virtual functions, file I/O, polymorphism, and accessing class members. The exam consists of 5 sections with 3 questions each, worth a total of 50 marks. Students are required to answer all questions, which involve explaining concepts, writing code examples, and analyzing/correcting code samples.

Uploaded by

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

Reg. No.

MANIPAL INSTITUTE OF TECHNOLOGY


Manipal University
Sixth SEMESTER B.Tech. (E & C) DEGREE END SEMESTER EXAMINATION
- April/May 2017
SUBJECT: OOP Using C++ (ECE - 4030)

TIME: 3 HOURS MAX. MARKS: 50


Instructions to candidates
 Answer ALL questions.
 Missing data may be suitably assumed.

1A. What are friend functions? Explain their characteristics. Illustrate with an example program, friend
function along with the main function which uses the friend function.
1B. Explain the syntax of new and delete operators. Demonstrate the use these operators with an
example program.
1C. Create a class called Time that has separate integer data members for hours, minutes, and seconds.
Write a constructor to initialize all these data to 0 or to values given by the user. Write a main
function which will exercise all the class member functions.
(5+3+2)
2A. What are classes and objects in C++? Explain with an example. Explain the access specifiers that
can be used in classes?
2B. What is memory leak? Explain how it is caused.

2C. Write an appropriate copy constructor for the following class. Write a main function which will
exercise all the class member functions. Is this a case of shallow copying or deep copying?
class Date {
int day, month, year;
public:
Date ( int, int, int );
set_date (int d, int m, int y);
void display ( void );
};

(5+3+2)
3A. Explain the issues faced in multiple inheritance and how are they resolved?
3B. Write the definitions for the below mentioned member functions of the class Time. Write a main
function which exercise all the member functions. Set the time to noon for the no-parameter
constructor.

class Time
{
int *hour,*minute,*second;

public:
Time ();
ECE- 4030 Page 1|3
Time ( int h, int m, int s );
void printTime ();
void setTime ( int h, int m, int s );
~Time();
};
3C. Define and explain multi-level inheritance with a relevant diagram.
(5+3+2)
4A. What is a virtual function? With example program, demonstrate the need and , usage of virtual
functions?
4B. For the class defined below, define constructor, destructor and copy constructor member functions.
Also write a main program which exercises all these member functions.

class Table
{ private:
int *p; int i;
};
4C. Consider the following class:

class Foo {
public:
void f1 (float s);
void f2 (const float &s);
void f3 (float s) const;
void f4 ( const float s);
private:
float n;
};
Which member function/s of the four member functions can/cannot legally alter member variable n?
Give one line reason for your answers.
(5+3+2)
5A. Explain the steps to open and close a file for I/O operation? Write a program to open a file and write
“Hello world” into it.
5B. Analyse the program given below. Point out error/s, if any ; give reason for error. Write the output
of the program ignoring the error/s.

class base //base class

{ public : virtual void show ( )=0;

};

class derv1 : public base

{ void show () { cout << “derv1\n”; }

};

ECE- 4030 Page 2|3


class derv2 : public base

public show ()

Cout << “derv2\n”;

};

int main ()

base b; base* arr[2];

derv1 dv1; derv2 dv2;

arr[0]= &dv1;

arr[2]= &dv2;

arr[0]->show ();

arr[1]->show ();

return 0;

5C. With an example, explain the two methods of accessing class’s members.

(5+3+2)

ECE- 4030 Page 3|3

You might also like