Reg. No.
FOURTH SEMESTER B.Tech. (E & C) DEGREE END SEMESTER EXAMINATION
APRIL 2018
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 classes and objects in C++? Explain with an example. Explain the access specifiers that
can be used in classes?
1B. Create a class called Time that has three int member data for hours, minutes, and seconds. One
constructor should initialize the time with zero values (reset), and another should initialize it to
values given by user. Another member function should display it, in 11:59:59 (am/pm) format.
Input Validation: Accept values only between 0 and 23 for the hour, between 0 and
59 for the minute and seconds. If any user given parameter is invalid, then set that parameter to
zero.
1C. What is a mutator function? Write a mutator function for the following class definition.
class Test {
int num;
};
(5+3+2)
2A. Explain shallow copy and deep copy with an example for each.
2B. For the class defined below, define constructor, destructor and copy constructor member functions.
Pointer variable, p must point to an array of 10 elements of char type. Also write a main program
which exercises all these member functions.
class Table
{ private:
char *p; int i;
};
2C. 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;
ECE – 4030 Page 1 of 2
};
Which member function/s of the four member functions could/could not legally alter member
variable n? Give one line reason for your answers.
(5+3+2)
3A. What are in-line functions? Illustrate with an example. What are their advantages and
disadvantages?
3B. Explain inheritance in C++? State the advantages of inheritance.
3C. What is a constant member function and what is its purpose?
(5+3+2)
4A. What are Abstract base classes? Explain the need of them with an example.
4B. Write the output of the following code snippet. Write one statement supporting your answer.
class Base
{
public:
virtual void show() { cout<<" In Base \n"; }
};
class Derived: public Base
{
public:
void show() { cout<<"In Derived \n"; }
};
int main(void)
{
Base *bp, b;
Derived d;
bp = &d;
bp->show();
bp = &b;
bp->show();
return 0;
}
4C. Explain multi-level inheritance with a relevant diagram.
(5+3+2)
5A. What is static polymorphism? Explain, with a code example, how it is implemented in C++.
5B. Explain the Exception handling mechanism in C++. Write an interactive program to compute square
of a positive number. The input value must be tested for validity. If it is negative the program
should raise an exception.
5C. Differentiate between function overloading and function overriding in C++.
(5+3+2)
ECE – 4030 Page 2 of 2