0% found this document useful (0 votes)
27 views

IT-107-Mid Term Paper-Spring 2021

Uploaded by

Khubaib Ishtiaq
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)
27 views

IT-107-Mid Term Paper-Spring 2021

Uploaded by

Khubaib Ishtiaq
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/ 2

UNIVERSITY OF GUJRAT

Mid Term Examination Spring 2021


Object Oriented Programming(Lab) Name : _____________________ Marks : 25
Course Code : IT– 107 Roll No: _____________________ Time : 90 Minutes

Create a class called Employee that includes three pieces of information as instance variables – a first
name (type String), a last name (type String) and a monthly salary (double).create a constructor in
above class to initialize the three instance variables.

Q.1) Create two employee objects and display each object’s yearly salary. [3]
Q.2) Give each employee a 10% raise and display each Employee’s yearly salary again. (Create and
Use Member function) [3]
----------------------------------------------------------------------------------------------------------------------------------
Write a class Array that contains an array of integers as data member. The class contains the following
member functions:

Q.3) A constructor that initializes the array elements to 0. [2]


Q.4) Input function to input the values in the array. [2]
Q.5) Show function to display the values of the array. [2]
Q.6) Overload == operator to compare the values of two objects. The overloaded function returns 1 if all
values of both objects are same and returns 0 otherwise. [2]
----------------------------------------------------------------------------------------------------------------------------------
Q.7) Answer the questions after going through the following class: [4]
class Test
{
char paper[20];
int marks;
public:
Test () // Function 1
{ strcpy (paper, "Computer");
marks = 0; }
Test (char p[]) // Function 2
{ strcpy(paper, p);
marks = 0; }
Test (int m) // Function 3
{ strcpy(paper,"Computer");
marks = m; }
Test (char p[], int m) // Function 4
{ strcpy (paper, p);
marks = m; }
};
Write statements in C++ that would execute
a) Function 1
b) Function 2
c) Function 3
d) Function 4
----------------------------------------------------------------------------------------------------------------------------------

Q.8) Using an object oriented programming language with which you are familiar write a class which contains
a method called getNumberOfInstances. This method should return the number of instances of the class [3]
Q.9) What will be the output of program?? [2]

1. #include <iostream>
2. using namespace std;
3. int main()
4. {
5. int const p = 5;
6. cout << ++p;
7. return 0;
8. }
Q10) What is the output of this program? [2]

1. #include <iostream>
2. using namespace std;
3. int g = 100;
4. int main()
5. {
6. int a;
7. {
8. int b;
9. b = 20;
10. a = 35;
11. g = 65;
12. cout << b << a << g;
13. }
14. a = 50;
15. cout << a << g;
16. return 0;
17. }

You might also like