0% found this document useful (0 votes)
51 views4 pages

Final Term Examination - February 2005: Time Allowed: 150 Minutes

The document contains instructions for a final term examination consisting of 13 multiple choice and coding questions worth a total of 100 marks. It instructs students to attempt all questions, show steps for coding questions, and warns against cheating. The questions cover topics like function overloading, class templates, friend functions, file I/O, destructors, arrays, and strings.

Uploaded by

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

Final Term Examination - February 2005: Time Allowed: 150 Minutes

The document contains instructions for a final term examination consisting of 13 multiple choice and coding questions worth a total of 100 marks. It instructs students to attempt all questions, show steps for coding questions, and warns against cheating. The questions cover topics like function overloading, class templates, friend functions, file I/O, destructors, arrays, and strings.

Uploaded by

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

Final Term Examination - February 2005

Time Allowed: 150 Minutes

Please read the following instructions carefully before attempting any of the
uestions:

1. Attempt all questions. Marks are written adjacent to each question.


2. Do not ask any questions about the contents of this examination from
anyone.
a. If you think that there is something wrong with any of the questions,
attempt it to the best of your understanding.
b. If you believe that some essential piece of information is missing,
make an appropriate assumption and use it to solve the problem.
c. Write all steps, missing steps may lead to deduction of marks.
d. All coding questions should be answered using the C ++ syntax.
You are allowed to use the Dev-C++ compiler to write and test your code. If you do
so please remember to copy and paste your code into the examination solution area.
(Do NOT share your code; your colleague could get higher marks than you!!)

**WARNING: Please note that Virtual University takes serious note of


unfair means. Anyone found involved in cheating will get an `F` grade in
this course.

Total Marks: 100 Total


Questions: 13

Question No. 1 Marks : 2

A function declaration has the same relationship to a function definition that

1 a class definition has to an object definition


2 an object declaration has to an object
3 a variable has to a variable declaration
4 a variable declaration has to the variable itself
5 they have no relationship

Question No. 2 Marks : 12


Write a function to overload subtraction operator for Class Order, which you created in
previous question. The class has following attributes/ data members
i) OrderID
ii) Items
iii) PricesOfItems

Write the main () to call the - operator and print the result also. This operator should subtract
the items of one object from the other.

Question No. 3 Marks : 4

What is the difference between an array and a structure?

Question No. 4 Marks : 2

When we write a class template the first line must be:

1 template < class class_type>


2 template < class data_type>
3 template < class T >, Here T can be replaced with any name but it is preferable.
4 class class-name()
5 class template<class_name>

Question No. 5 Marks : 2

A friend function of a class has access

1 To all data member and functions of the class


2 Only to other friend functions of the class
3 Only to private data of the class
4 Only to public data of the class
5 To private data declared in main()

Question No. 6 Marks : 5

Briefly describe the role of each of the following within a class:

1. Instance variables
2. Instance methods
3. Constructors

Question No. 7 Marks : 20

Create a class named Order. This class has the following attributes/ data members
i) OrderID
ii) Items
iii) PricesOfItems
a) Create the object of this class using parameterized constructor in order to initialize
OrderID and Items data members. Default values of both the data members must be
equal to 1.
b) Write the following member functions of this class;
i) OrderBill ( ), this function will calculate the invoice of an order and display the
result. The formula to calculate the invoice is
invoice=SumPrices();

ii) SumPrices( ), this function will sum the prices of the items entered by the user
from
keyboard in PricesOfItems array and returns the result.

c) Write the setter functions for OrderID, Items, and PricesOfItems. And getter functions
for OrderID and Items.

Also write the main () to create the object of class Order.

Question No. 8 Marks : 2

The new operator

1 is used to declare objects or variables


2 can not create and initialize an object
3 names an object or variable
4 returns an address to an object or variable
5 can allocate an appropriate amount of memory for an object or variable

Question No. 9 Marks : 15

Write a program that inputs one string of max length of 10. If the string is identical to "Virtual",
output the message "Correct Password"; otherwise, output the first four characters in the
message and the length of the message.

Question No. 10 Marks : 2

If we open a file stream myfile for reading, what will give us the current position of the file
pointer?

1 tellg()
2 tellp()
3 seekg()
4 seekp()
5 fstream.h

Question No. 11 Marks : 2

There is a class Student, Which one of the following is a valid destructor for this class.

1 Student();
2 Student(int);
3 ~ Student();
4 int~ Student();
5 ~ Student(int);

Question No. 12 Marks : 5

What is a friend function? Explain with example?

Question No. 13 Marks : 6

Write code that will declare, initialize, and fill in an array of objects of type int. After your code
executes, the array should look as follows.

0 2 4 6 8 10 12 14 16 18

You might also like