BEU B.Tech 3rd Semester C++ OOP PYQ 2019
Download BEU B.Tech 3rd Semester OOP Using C++ Previous Year Question Paper (2019). Get complete questions on OOP, polymorphism, classes, inheritance, constructor, destructor, exception handling, and more. Helpful for exam preparation.

B.Tech 3rd Semester Exam 2019 (New Course)
Code: 100313
OBJECT-ORIENTED PROGRAMMING USING C++
Time: 3 Hours
Full Marks: 70
Instructions:
The marks are indicated in the right-hand margin.
There are NINE questions in this paper.
Attempt FIVE questions in all.
Question No. 1 is compulsory.
How marks are assigned in this paper
Question 1 → 2 marks × 7 = 14 marks
Question 2 to 9 → Each question has two sub-questions, each 7 marks:
7 + 7 = 14 marks per questionYou have to attempt FIVE questions in total including Q1 (which is compulsory).
So your final selection is:
Q1 → 14 marks
Any 4 more from Q2–Q9 → 4 × 14 = 56 marks
Total = 70 marks
1. Choose the correct answer (any seven)
(a) Which feature allows open recursion among the following?
(i) Use of this pointer
(ii) Use of pointers
(iii) Use of pass-by-value
(iv) Use of parameterized constructor
(b) If the same message is passed to objects of several different classes and all of them respond in different ways, what is this feature called?
(i) Inheritance
(ii) Overloading
(iii) Polymorphism
(iv) Overriding
(c) Which among the following is wrong?
(i) class student{}; student s;
(ii) abstract class student{}; student s;
(iii)
abstract class student{}
s[50000000];
(iv)
abstract class student{};
class toppers : public student{};
topper t;
(d) If two classes combine some private data members and provide public member functions to access and manipulate those data members, where is abstraction used?
(i) Using private access specifier for data members
(ii) Using class concept with both data members and member functions
(iii) Using public member functions to access and manipulate the data members
(iv) Data is not sufficient to decide what is being used
(e) Which class/set of classes can illustrate polymorphism in the following code?
abstract class student {
public:
int marks;
calc_grade();
};
class topper : public student {
public:
calc_grade() {
return 10;
}
};
class average : public student {
public:
calc_grade() {
return 20;
}
};
class failed { int marks; };
(i) Only class student can show polymorphism
(ii) Only class student and topper together can show polymorphism
(iii) All class student, topper and average together can show polymorphism
(iv) Class failed should also inherit class student for this code to work for polymorphism
(f) Consider the following code and select the correct option:
class student {
int marks;
public:
int* fun() {
return &marks;
}
};
main() {
student s;
int *ptr = s.fun();
return 0;
}
(i) This code is good to go
(ii) This code may result in undesirable conditions
(iii) This code will generate error
(iv) This code violates encapsulation
(g) Which among the following is correct for the class defined below?
class student {
int marks;
public:
student() {}
student(int x) {}
};
marks = x;
}
main() {
student s1(100);
student s2();
student s3 = 100;
return 0;
}
(i) Object s3, syntax error
(ii) Only object s1 and s2 will be created
(iii) Program runs and all objects are created
(iv) Program will give compile-time error
(h) Does constructor overloading include different return types for constructors to be overloaded?
(i) Yes, if return types are different, the signature becomes different
(ii) Yes, because return types can differentiate two functions
(iii) No, return type can’t differentiate two functions
(iv) No, constructors don’t have any return type
(i) Which constructor will be called from the object created in the code below?
class A {
int i;
A() {
i = 0;
cout << i;
}
A(int x = 0) {
i = x;
cout << i;
}
};
A obj1;
(i) Default constructor
(ii) Parameterized constructor
(iii) Compile-time error
(iv) Run-time error
(j) When an object is passed to a function, its copy is made in the function, and then:
(i) The destructor of the copy is called when function is returned
(ii) The destructor is never called in this case
(iii) The destructor is called but it is always implicit
(iv) The destructor must be user-defined
Question 2.
(a) What is Object-oriented Programming (OOP)? Write the basic concepts of OOP.
(b) What do you mean by class and object?
Question 3.
(a) With an example, explain the terms constructor and destructor.
(b) With an example, explain what a virtual function is.
Question 4.
(a) What do you mean by polymorphism?
(b) With an example, differentiate between run-time and compile-time polymorphism.
Question 5.
(a) What is a friend function?
(b) What is a pure virtual function?
Question 6.
(a) What is an abstract class? Write a program to illustrate. Also outline the advantages of an abstract class.
(b) Differentiate between abstract class and interface.
Question 7.
What are various types of inheritance, shown in the following figure?

Question 8.
(a) What is an exception? What do you mean by exception handling?
(b) Explain the keywords: try, catch and throw.
Question 9.
With the help of an example program, differentiate between the following:
(a) Overloading vs. Overriding
(b) Early binding vs. Late binding
Got it.
You want exactly this format:
First the question as it is
Then the options exactly as given
Then mark the correct option inside the list itself (like ✔)
Then explanation below
I’ll follow this format perfectly now.
1. Choose the correct answer (any seven)
(a)Which feature allows open recursion among the following?
(i) Use of this pointer ✔
(ii) Use of pointers
(iii) Use of pass-by-value
(iv) Use of parameterized constructor
Explanation:
Open recursion happens when an object calls its own methods.this pointer gives access to the current object, so it enables open recursion.
(b) If the same message is passed to objects of several different classes and all of them respond in different ways, what is this feature called?
(i) Inheritance
(ii) Overloading
(iii) Polymorphism ✔
(iv) Overriding
Explanation:
Polymorphism means one function name gives different behaviours in different classes.
(c) Which among the following is wrong?
(i) class student{}; student s;
(ii) abstract class student{}; student s; ✔
(iii) abstract class student{}
s[50000000];
(iv) abstract class student{};
class toppers : public student{};
topper t;
Explanation:
You cannot create an object from an abstract class.
So statement (ii) is wrong.
(d) If two classes combine some private data members and provide public member functions to access and manipulate those data members, where is abstraction used?
(i) Using private access specifier for data members ✔
(ii) Using class concept with both data members and member functions
(iii) Using public member functions
(iv) Data is not sufficient
Explanation:
Abstraction mainly comes from hiding details using private members.
(e) Which class/set of classes can illustrate polymorphism in the following code?
(i) Only class student
(ii) student and topper
(iii) student, topper and average ✔
(iv) failed should inherit student
Explanation:
Polymorphism needs base + derived classes overriding a function.
student → topper & average satisfy this.
(f) Consider the following code and select the correct option:
(i) This code is good to go
(ii) This code may result in undesirable conditions ✔
(iii) This code will generate error
(iv) This code violates encapsulation
Explanation:
Returning address of a private data member works but is risky.
It exposes internal data → unsafe.
(g) Which among the following is correct for the class defined below?
(i) Object s3, syntax error
(ii) Only object s1 and s2 will be created
(iii) Program runs and all objects are created
(iv) Program will give compile-time error ✔
Explanation:
There is stray code outside the constructor → compile error.
(h) Does constructor overloading include different return types for constructors to be overloaded?
(i) Yes, if return types are different
(ii) Yes, return types can differentiate
(iii) No, return type can’t differentiate
(iv) No, constructors don’t have any return type ✔
Explanation:
Constructors have no return type, so overloading cannot depend on return type.
(i) Which constructor will be called from the object created?
(i) Default constructor
(ii) Parameterized constructor
(iii) Compile-time error✔
(iv) Run-time error
Explanation:
Both constructors behave like default constructors. This causes ambiguity, so the program fails to compile.
(j) When an object is passed to a function, its copy is made in the function, and then:
(i) The destructor of the copy is called when function returns ✔
(ii) The destructor is never called
(iii) The destructor is called but always implicit
(iv) The destructor must be user-defined
Explanation:
Passing object by value creates a temporary copy.
When function ends, that temporary object is destroyed → destructor called.
Question 2.
(a) What is Object-oriented Programming (OOP)? Write the basic concepts of OOP.
(b) What do you mean by class and object?
Answer
(a) Object-oriented Programming (OOP)
Object-oriented Programming is a programming method where we build programs using objects.
Each object stores data and functions together so that the program becomes easier to manage, reuse, and understand.
OOP helps in real-world modelling because everything is treated as an object.
• OOP uses objects instead of writing everything in one block
• It helps in reusing code
• It protects data by controlling access
• It makes big programs easy to handle
Basic concepts of OOP
• Class – A blueprint that defines data and functions
• Object – A real instance created from a class
• Encapsulation – Binding data and functions together and hiding the internal details
• Abstraction – Showing only necessary features and hiding the background details
• Inheritance – One class can acquire properties of another class
• Polymorphism – Same function name showing different behaviours in different classes
example
If we create a class Car, then every actual car like car1, car2 becomes an object with its own color, speed, etc.
(b) Class and Object
A class is a template or model that tells what data and functions an object will have.
An object is an actual unit created from a class, holding its own data values.
• A class only describes things, it does not occupy memory
• An object is created from a class using the class name
• Many objects can be created from one class
• Each object has its own copy of data
example
If class Student defines name and roll number, then Student s1 and Student s2 are objects with their own name and roll number.
Question 3.
(a) With an example, explain the terms constructor and destructor.
(b) With an example, explain what a virtual function is.
Answer
(a) Constructor and Destructor
A constructor is a special function in a class that runs automatically when an object is created.
It is used to set initial values or allocate resources.
A destructor is a special function that runs automatically when an object is destroyed.
It is used to clean up memory or close resources.
• Constructor has the same name as the class
• Constructor has no return type
• Destructor also has the same name but starts with ~
• Destructor is called only once when the object goes out of scope
• They help in setting up and cleaning up an object’s life cycle
Simple example
class Demo {
public:
Demo() { cout << "Constructor called"; }
~Demo() { cout << "Destructor called"; }
};
int main() {
Demo obj;
}
In this example, when obj is created, the constructor runs.
When main ends, obj is destroyed, so the destructor runs.
(b) Virtual Function
A virtual function is a function in the base class that can be redefined in the derived class, and which one gets called depends on the object at runtime.
It helps achieve runtime polymorphism.
• Declared using the keyword virtual in the base class
• It allows the program to decide the function call based on the actual object
• It is useful when base pointers point to derived objects
• It supports dynamic binding
Simple example
class Animal {
public:
virtual void sound() { cout << "Animal makes a sound"; }
};
class Dog : public Animal {
public:
void sound() { cout << "Dog barks"; }
};
int main() {
Animal* a = new Dog();
a->sound();
}
In this example, even though the pointer is of Animal, the function of Dog runs because sound() is virtual.
Question 4.
(a) What do you mean by polymorphism?
(b) With an example, differentiate between run-time and compile-time polymorphism.
Answer
(a) What do you mean by polymorphism?
Polymorphism means one function name can show different behaviours depending on the object or the situation.
It allows the same action to work in different ways, making programs flexible and easy to extend.
• Same function name can work differently
• Helps in code reusability
• Makes programs easier to maintain
• Achieved by function overloading, operator overloading, and virtual functions
Simple example
If two different classes have the same function show(), each object will run its own version of show().
(b) With an example, differentiate between run-time and compile-time polymorphism.
Compile-time polymorphism happens when the decision of which function to call is made during compilation.
This is done using function overloading or operator overloading.
Run-time polymorphism happens when the decision of which function to call is made while the program is running.
This is done using virtual functions and base-class pointers.
• Compile-time polymorphism uses function overloading
• Run-time polymorphism uses virtual functions
• Compile-time is resolved by the compiler early
• Run-time is resolved when the program actually runs
Simple example
Compile-time polymorphism (function overloading)
class Demo {
public:
void show(int x)
{
cout << "Integer";
}
void show(double y)
{
cout << "Double";
}
};
Here the correct show() function is chosen during compilation.
Run-time polymorphism (virtual function)
class Base {
public:
virtual void greet() { cout << "Base"; }
};
class Derived : public Base {
public:
void greet() { cout << "Derived"; }
};
Base* b = new Derived();
b->greet();
Here the function is chosen during program execution, so Derived version runs.
Difference Between Compile Time And Run Time Polymorphism
Compile-Time Polymorphism | Run-Time Polymorphism |
|---|---|
It is also called Static Polymorphism. | It is also known as Dynamic Polymorphism. |
In compile-time polymorphism, the compiler determines which function or operation to call based on the number, types, and order of arguments. | In run-time polymorphism, the decision of which function to call is determined at runtime based on the actual object type rather than the reference or pointer type. |
Function calls are statically binded. | Function calls are dynamically binded. |
Compile-time Polymorphism can be exhibited by: 1. Function Overloading | Run-time Polymorphism can be exhibited by Function Overriding. |
Faster execution rate. | Comparatively slower execution rate. |
Inheritance in not involved. | Involves inheritance. |
Question 5.
(a) What is a friend function?
(b) What is a pure virtual function?
Answer
(a) What is a friend function?
A friend function is a special function that is not a member of a class but still has the right to access the private and protected data of that class.
Normally, private data cannot be accessed from outside the class, but sometimes we need an external function to work closely with the class.
In such situations, we mark that function as a friend so that it gets special permission.
• Declared using the keyword friend inside the class
• Can access private and protected members directly
• It is not part of the class, so it is called like a normal function
• Useful when two classes need to share data
• Helps in operator overloading (like overloading << and >>)
Simple example
class Box {
private:
int width;
public:
Box(int w) : width(w) {}
friend void show(Box b); // friend function
};
void show(Box b) {
cout << b.width; // allowed because show() is a friend
}
Here, show() is not inside the class, but it can still read width because it is a friend function.
(b) Pure Virtual Function
A pure virtual function is a function in the base class that has no body and must be overridden in the derived class.
It is used when the base class only defines a common structure but does not provide any implementation.
A class that contains a pure virtual function becomes an abstract class, which means you cannot create objects of it.
• Written with = 0 at the end
• Forces derived classes to give their own function definition
• Makes the base class abstract
• Used to create a common interface for all derived classes
• Helps in achieving runtime polymorphism
Simple example
class Shape {
public:
virtual void area() = 0; // pure virtual function
};
class Circle : public Shape {
public:
void area() { cout << "Circle area"; }
};
Here, Shape only declares the function area() but does not define it.Circle must define area(); otherwise, it cannot create objects.
Question 7.
What are various types of inheritance, shown in the following figure?

Answer
(i) Figure one is Single Inheritance
Single inheritance means one subclass inherits from one superclass.
This creates a simple one-to-one relationship.
• Only one parent class
• Only one child class
• Child directly gets properties and functions of the parent
• Very easy and common type of inheritance
Figure meaning:
Class B is inheriting from class A.
A → B
Simple example:
A class Animal inherited by class Dog.
Dog gets all features of Animal.
(ii)Figure two is Multiple Inheritance
Multiple inheritance means one subclass inherits from more than one superclass.
The child class combines features of all parent classes.
• One child class
• Two or more parent classes
• Child can use both parents’ data and functions
• Useful when one class must carry mixed behaviour
Figure meaning:
Class C is inheriting from A and B.
A →
C
B →
Simple example:
A class FlyingCar inherits from both Car and Airplane.
It gets properties of both.
(iii) Figure three is Multilevel Inheritance
Multilevel inheritance means inheritance happens in a chain.
One class becomes a parent of another class, and that class again becomes a parent of the next.
• Grandparent → Parent → Child chain
• Features flow from top to bottom
• Each level adds new behaviour
Figure meaning:
A → B → C
A is parent of B, and B is parent of C.
Simple example:LivingThing → Animal → Dog
Dog gets features from both Animal and LivingThing.
Question 8.
(a) What is an exception? What do you mean by exception handling?
(b) Explain the keywords: try, catch and throw.
Answer
(a) Exception and Exception Handling
An exception is an unexpected event or error that happens while the program is running.
It stops the normal flow of the program.
Common examples include dividing by zero, accessing invalid memory, or opening a file that does not exist.
Exception handling means writing special code to manage these errors in a safe way so the program does not crash.
It allows the program to continue running or show a proper message instead of stopping suddenly.
• Exceptions happen during runtime
• Exception handling prevents program crashes
• It separates normal code from error-handling code
• It uses try–catch–throw to detect and manage errors
Simple example
int a = 10, b = 0;
try {
if(b == 0)
throw "Cannot divide by zero";
cout << a / b;
}
catch(const char* msg) {
cout << msg;
}
Here, dividing by zero is an exception, and the catch block handles it safely.
(b) try, catch and throw
trytry contains the code that may cause an exception.
If something goes wrong inside the try block, the program jumps to the catch block.
• Used to wrap risky code
• No error inside try → catch is skipped
• Error inside try → exception is thrown
Simple example
try {
int x = -1;
if(x < 0)
throw x;
}
catchcatch is used to receive and handle the exception thrown by the try block.
It decides what to do when an error occurs.
• Runs only when an exception is thrown
• Can display error messages
• Can perform cleanup or recovery
Simple example
catch(int n) {
cout << "Negative number: " << n;
}
throwthrow is used to send (raise) an exception from inside the try block.
Any value or object can be thrown.
• It stops normal flow immediately
• It sends control to the matching catch block
• Used to report an error condition
Simple example
throw 5; // throwing an integer exception
In summary:
• try = code that may fail
• throw = raise the error
• catch = handle the error
Question 9.
With the help of an example program, differentiate between the following:
(a) Overloading vs. Overriding
(b) Early binding vs. Late binding
Answer
(a) Overloading vs. Overriding
Overloading
Overloading means using the same function name with different parameter lists inside the same class.
The compiler decides which version to use based on the arguments.
This happens during compilation.
• Same name, different parameters
• Happens in the same class
• Decided at compile time
• Called compile-time polymorphism
Simple example (Function Overloading)
class Demo {
public:
void show(int x) { cout << "Integer"; }
void show(double y) { cout << "Double"; }
};
int main() {
Demo d;
d.show(5); // calls first function
d.show(3.5); // calls second function
}
Code Flow
Program enters
main().Object
dof classDemois created.d.show(5)is called → argument is int, so compiler selectsvoid show(int)→ prints “Integer”.d.show(3.5)is called → argument is double, so compiler selectsvoid show(double)→ prints “Double”.Program ends.
Overriding
Overriding means redefining a base class function in the derived class using the same name and same parameter list.
The function called depends on the object at runtime.
• Same name, same parameters
• Happens between base and derived classes
• Needs inheritance
• Uses virtual keyword for runtime binding
Simple example (Function Overriding)
class Base {
public:
virtual void greet()
{
cout << "Base";
}
};
class Derived : public Base {
public:
void greet() { cout << "Derived"; }
};
int main() {
Base* b = new Derived();
b->greet(); // calls Derived version
}
Code Flow
Program starts and creates a pointer
bof typeBase*.bis assigned an object ofDerived(new Derived()).b->greet()is called.Because
greet()in Base is marked virtual, C++ checks the actual object (Derived).It calls
Derived::greet()→ prints “Derived”.Program ends.
(b) Early Binding vs. Late Binding
Early Binding
Early binding means the function call is decided by the compiler before the program runs.
This is used in normal function calls and overloaded functions.
• Happens at compile time
• Fast execution
• No virtual keyword needed
• Used in function overloading
Simple example of early binding
class Test {
public:
void show() { cout << "Show"; }
};
int main() {
Test t;
t.show(); // fixed at compile time
}
Code Flow
Program enters
main().Object
tis created.t.show()is directly linked to the functionshow()by the compiler.No decision needed at runtime.
It prints “Show”.
Program ends.
Late Binding
Late binding means the function call is decided while the program is running.
This happens using virtual functions with base-class pointers.
• Happens at runtime
• Slower but flexible
• Needs virtual keyword
• Used in overriding
Simple example of late binding
class Base {
public:
virtual void display() { cout << "Base"; }
};
class Child : public Base {
public:
void display() { cout << "Child"; }
};
int main() {
Base* ptr = new Child();
ptr->display(); // decided at runtime
}
Code Flow
Program enters
main().Pointer
ptrof typeBase*is created.ptrpoints to aChildobject (new Child()).ptr->display()is called.Because
display()in Base is virtual, C++ checks the actual object type at runtime.Actual object is
Child, so it callsChild::display()→ prints “Child”.Program ends.
These notes cover the important concepts of Object-Oriented Programming such as overloading, overriding, inheritance, polymorphism, virtual functions, constructors, destructors, exception handling, and binding.
All the explanations are written in simple language so any B.Tech CSE student can understand them easily without confusion.
Hi am from Madhepura College of Engineering, make sure to revise these topics well because they come frequently in AKU/BEU exams.
You can also share these notes with your friends and classmates so everyone can prepare better.
Good notes help you revise faster, save time, and improve your exam performance.
Keep learning, keep practicing, and help others too.
For any error please report us