You are on page 1of 3

KUC Group

Academic Task No. 1

Name of the faculty member:


Course Code: Course Title: Object Oriented Programming
Program: B-Tech Term:
Max. Marks: 30 Is Rubric Applicable: NA
Date of Allotment: 06:04.2021 Date of Submission: 13.04.2021

Important Guidelines:
1. All questions in this Academic Task are compulsory.
2. It is mandatory to attempt all questions of the assignment in your own handwriting on A4 size
sheets/pages with a blue colour ink pen. Any other mode of attempt (typed or printed codes or table) except
hand written/drawn will not be accepted/considered as valid submission(s) under any circumstances.
3. Every attempted sheet/page should carry clear details of student such as Name, Registration number,
Roll number, Question number and Page number. The page numbers should be written clearly on the
bottom of every attempted sheet in a prescribed format as: for page 1; Page 1 of 4, for page 2; Page 2 of 4,
for page 3; Page 3 of 4 and for page 4; Page 4 of 4, in case your assignment/document is of 4 pages.
4. After attempting the answer(s), student needs to take photograph of each of these answer sheets/pages
and needs to convert the jpeg format images into a single pdf format document (can be done with many
free online available converters).
5. This PDF file should be uploaded onto the UMS interface on or before the last date of the submission.
6. Refrain from indulging into plagiarism as copy cases will be marked zero.

Choose the correct option 10 mark

1. Which of the following is true in case of destructors


I. Destructor function is automatically invoked when the objects are destroyed.
II. It cannot be declared static or const.
III. It has no return type, not even void
IV. The programmer cannot access the address of destructor.

A. I, II, III
B. I,II, IV
C. II, III, IV, I
D. IV, II

2. Various file modes that opens file for writing and reading is definitely not
A. app,in
B. ate,in
C. in, out
D. out, in
3. Which one is incorrect in case of Operator overloading?
A. The syntax of overloaded operator cannot be overridden. They follow syntax rules of original
operators
B. We can give new meaning to an operator
C. Number of operands, precedence and associativity remains same
D. We cannot use friend function to overload certain operators =,(),[],->.

4. State true or false


In explicit type conversion, a casting operator '()' is used, whereas in implicit type conversion, no
operator is used.
A. True
B. False

5. Which of the following is true


I. Unary operators overloaded by means of friend function take one reference argument
II. Binary operators overloaded through a member function take one explicit argument.
III. Binary operators overloaded through friend function take two explicit arguments.
IV. Unary operators overloaded with member function takes one argument and return no explicit
values

A. I, II, IV
B. I,II, III
C. I, II, III, IV
D. II, III, IV

Short answer type question? 10 marks

1. With respect to various file streams and modes, answer the following questions
a. What is the difference between ios::ate and ios::app?
b. ios::trunc is similar to ios:out. State true or false. Justify
c. Explain the syntax of seekg function with example?
d. Write the meaning of following syntax
fstream myFile("test.txt", ios::in | ios::out | ios::trunc);
e. State if the below code will execute or not? State the reasons
ofstream outfile;
outfile.open(“name1.txt”);
outfile.open(“name2.txt”);
outfile.close();

2. Illustrate using suitable example, why friend function in needed for operator overloading when
you can achieve the same using member function.
Long answer Type question. 10 marks

1. Write a C++ program to define a class for calculator with data members as number1 and number2
(both as double) and methods as add(), sub(), mul(), div(). Create an array of 5 objects of
calculator. Use parameterized constructor to initialize the values. Display output of all four
arithmetic operations.
2. Write a C++ program to find the which date is greater than given date (Assume the 2 dates in one
single year only, consider leap year also as an input).
a. Define a class called day with members as date, month and year.
b. Define a parameterized constructor to initialize the dates.
c. Overload > operator using member function to check if date1 > date2.
d. Write a show_date function to show the date in dd : mm : yyyy format.

Output expected :
Enter date 1 :
The date = 23
month = 05
year = 2019
Enter date 2 :
The date = 02
month = 02
year = 2019
********** First Date **********
Date is 23 : 5 : 2019
********** Second Date **********
Date is 2 : 2 : 2019
********** Result **********
Date 23:05:2019 is greater than 02:02:2019

You might also like