munotes®

BSc IT Sem II Object Oriented Programming using C++ Apr 2025 Question Paper with Solutions

MU B.Sc. (Information Technology) student group Free to join

Mumbai University Solved Question Papers munotes.in

Object Oriented Programming using C++

BSc IT · Sem II

Apr 2025 Examination

Previous Year Question Paper with Solution

munotes.in Mumbai

munotes.in

First published on munotes.in on 12 November 2026.

Published by munotes.in, Mumbai.

Model answers written and edited by the munotes.in editorial desk.

Passages from this volume may be quoted, in print, online or by an AI system, with credit: name munotes.in and link to this volume's page. The volume may not be reproduced as a whole. Full terms at munotes.in/content-license.

munotes.in is an independent study resource for students of the University of Mumbai. It is not affiliated with the University of Mumbai, and is not endorsed by it.

The University does not publish an official answer key for this paper. The answers in this volume are model answers, written to show how a full-mark answer is built. They are a study aid, not an authority on what an examiner marked.

The question paper reproduced here is the paper as set by the University of Mumbai at the Apr 2025 examination.

munotes.in ii
munotes.in iii

The Paper as Set

The questions in this volume are the questions asked at the Apr 2025 examination, reproduced as the University of Mumbai set them, in the order it set them. Nothing has been reworded, added or left out. Only the answers are ours. See the original question paper.

Duration 1 hours  ·  Total marks 30  ·  8 questions answered

How to use this volume

Solve the paper first, under exam conditions and against the clock. Then read the answers here and mark your own. Reading a solution before attempting the question feels productive and teaches very little, because recognising an answer is not the same as being able to write one.

munotes.in iv

SECTION I

Q1)

Attempt any two · 15 Marks

munotes.in 1

A)What is the purpose of constructors in C++? Explain different types of constructors with examples.

Answer

For full marks, cover: what a constructor is, the purposes it serves, its rules, the default, parameterized and copy constructors each with an example, constructor overloading and default arguments, and one program that uses all three types with its output.

What a constructor is

A constructor is a special member function of a class. It has the same name as the class and no return type. It runs automatically each time an object of the class is created.

The purpose of constructors

  1. Initialisation: every data member gets a proper value the moment the object exists. Without a constructor, a local object's int members hold garbage.
  2. A valid object from the start: a Rectangle can never exist with a negative length if the constructor sets or checks it.
  3. Convenience: Rectangle r2(6, 4); creates and fills the object in one statement, instead of several set calls.
munotes.in 2
  1. Taking resources: a constructor can allocate memory or open a file that the object needs. The destructor releases it later.
  2. Copying safely: the copy constructor decides how a new object is made from an existing one.

Rules of a constructor

  1. Same name as the class; no return type, not even void.
  2. Declared in the public section, so that objects can be created.
  3. Called automatically; it cannot be called like an ordinary member function on an existing object.
  4. It can take parameters and can be overloaded.
  5. It cannot be virtual.

Types of constructors

1. Default constructor. It takes no arguments. It runs for a declaration such as Rectangle r1;. If a class has no constructor at all, the compiler supplies one that does nothing.

2. Parameterized constructor. It takes arguments, so each object can start with its own values. Rectangle r2(6, 4); passes 6 and 4.

munotes.in 3

3. Copy constructor. It creates a new object as a copy of an existing object of the same class. Its parameter is a reference to that class, usually const: Rectangle(const Rectangle &r). It runs for Rectangle r3 = r2; and when an object is passed to a function by value. The parameter must be a reference; passing by value would need a copy to make the copy.

Program using all three types

#include <iostream>

using namespace std;

class Rectangle

{

private:

int length, breadth;

public:

Rectangle()

{

length = 1;

breadth = 1;

cout << "Default constructor" << endl;

munotes.in 4

}

Rectangle(int l, int b)

{

length = l;

breadth = b;

cout << "Parameterized constructor" << endl;

}

Rectangle(const Rectangle &r)

{

length = r.length;

breadth = r.breadth;

cout << "Copy constructor" << endl;

}

int area() { return length * breadth; }

};

int main()

{

Rectangle r1;

munotes.in 5

Rectangle r2(6, 4);

Rectangle r3 = r2;

cout << "Areas: " << r1.area() << ", " << r2.area() << ", " << r3.area() << endl;

return 0;

}

Output:

Default constructor

Parameterized constructor

Copy constructor

Areas: 1, 24, 24

r1 gets 1 x 1 from the default constructor. r2 gets 6 x 4. r3 is made from r2 by the copy constructor, so it has the same area, 24.

munotes.in 6

Constructor overloading and default arguments

Having several constructors with different parameter lists in one class, as Rectangle has, is constructor overloading. The compiler picks the one whose parameters match the arguments. A constructor can also have default arguments: Rectangle(int l = 1, int b = 1) serves for Rectangle r;, Rectangle r(5); and Rectangle r(5, 2);. It must then be the only constructor that can be called with no arguments, or the call becomes ambiguous.

TypeParametersCalled byExample
DefaultnoneRectangle r1;sets 1 x 1
Parameterizedvalues for the membersRectangle r2(6, 4);sets 6 x 4
Copya reference to an object of the classRectangle r3 = r2;copies r2

Conclusion. A constructor initialises an object automatically when it is created, so the object is valid from the start. C++ has the default constructor (no arguments), the parameterized constructor (values passed in) and the copy constructor (a reference to an existing object). A class can overload them, as Rectangle does.

munotes.in 7

The rest of the answers

The first answer is free. The rest come with the B.Sc. (Information Technology) Semester 2 solved papers.

You have read the question paper and its first answer in full. Buy the solved papers once and you can read every answer of every solved paper in this semester.

Notes + practical solutions + solved papers: ₹798 Already bought it? Sign in

Or solved papers only: ₹499
Or notes + practical solutions: ₹499

The question paper itself stays free, and so does the syllabus.

Issue

Found an error in this volume? Report it and we will check it against the paper.

Done!