Professional Documents
Culture Documents
INSTRUCTIONS (1) Answer all questions. (2) No books, notes, paper or other material is allowed in your possession. (3) Understanding the problem is the part of the exam, therefore NO QUERIES shall be entertained. (4) This paper consists of 3 pages. (Please check before commencing) (5) For theory based concepts remain precise and effective. (6) For programming exercises, syntax follow requirements, naming conventions, code/algorithmic efficiency, appropriate comments, clarity of the code etc. (7) You will not be penalized for any wrong answer. (8) Proposed time division is as follows a) 10 minutes (pre and post write reading). b) 110 minutes (Attempting the paper)..
GOOD LUCK
Q1. (a) (10 + 10) class xyz { private: int x,y ,z; int *p; public: xyz(int a, int b, int c, int n) { x=a; y=b; z=c; p=new int[n]; } . . . }; Write a code of copy constructor for the above class. During this take care of dangling pointer problem. (b) Class complexNumber { private: int real, img; public: complexNumber(int r=0, int i=0) { real=r; img=i; } . . . }; Write a code to overload + Operator(+). that adds two complex numbers.
Superior University Lahore Q2. Define following (5+4+5+3+3) i) Inline and offline function ii) This Pointer iii) Differentiate between class and object iv) Encapsulation v) Abstraction Q3. ( 20) Make a class Employee. Its attributes are name (string), id(int), Salary(int). write its setter, getter and default parameterized constructor. Also instantiate this class in main function. Q4. (a) Write a template function for the following. int sun (int a, int b) { return a+b; } (b) Write note on following: i) Constructor ii) Destructor iii) Static Variable Q5. (a) Design UML (Class Diagram) for following passage. (14 + 6) (7 + 13)
You are going to design Employee Management System. There are several departments like Accounts and HR. There are several employees. Employees are of following types i) Permanent ii) Contractual Permanent employees are of further two types. i) full time ii) part time HR department is responsible to hire all employees and employees are referred to accounts department for their salary collection. Each department consist of number of employees. (b) Identify Relationships among the following entities i) Teacher teaches students ii) Circle is a shape iii) Car have four tyres iv) Shirt have buttons