Professional Documents
Culture Documents
Instructions:
Before starting your open book examination, please read all the given below instructions carefully,
and must follow these instructions carefully. You must affirm the honesty pledge given at the end:
1. Change the answer booklet FILE-NAME to your own Name & Reg#
E.g. 321_Ahmed_Ali.docx
2. Download the question paper titled as “<Name of the Course> Question Paper.pdf” (pdf file)
and answer-sheet titled as “<Name of the Course> _Answer-Booklet.docx” (MS Word
document) from the Google Classroom as per instructions of your teacher. You are required to
write down the answers to each question in your own handwriting on neat white papers with any
blue pen.
3. Maximum time to download question paper, attempt and submit/ upload your answer sheets
is 3 HOURS. As soon as you finish your paper Upload your answer booklet on priority basis.
soon. You can only upload your exam response once. You will be unable to re-upload an additional
or amended version. If you fail to submit it within the due time, your paper will be considered
cancelled.
Page 1 of 14
INTERNATIONAL ISLAMIC UNIVERSITY, ISLAMABAD
FACULTY OF BASIC & APPLIED SCIENCES
DEPARTMENT OF COMPUTER SCIENCE & SOFTWARE ENGINEERING
5. The University views copying from one another's examination paper/ cheating, giving or receiving
unpermitted aid, discussion/consultation, plagiarism, impersonation during an examination, as
serious disciplinary offences that may fall under the category of Use of Unfair Means and will be
dealt as per university rules for UMCC.
6. Before starting your examination, you must agree to and sign the following pledge by having a click
on the Student’s Affirmation check box (it is mandatory to Tick the Checkbox):
“I hereby affirm that i) I shall solve this paper on my own and I shall not seek the help
of any person(s) with any sort of aid (like telephonic/verbal help, attempted answers
related to my examination etc.) while taking my paper, (ii) or will not provide
assistance of any sort (verbal or written) to other fellow students. If I am found
involved in i) cheating ii) impersonation, iii) or using plagiarized content in my writing,
my case may be dealt as per university rules and procedures for using unfair means.”
Page 2 of 14
INTERNATIONAL ISLAMIC UNIVERSITY, ISLAMABAD
FACULTY OF BASIC & APPLIED SCIENCES
DEPARTMENT OF COMPUTER SCIENCE & SOFTWARE ENGINEERING
Page 3 of 14
INTERNATIONAL ISLAMIC UNIVERSITY, ISLAMABAD
FACULTY OF BASIC & APPLIED SCIENCES
DEPARTMENT OF COMPUTER SCIENCE & SOFTWARE ENGINEERING
Q1.
Page 4 of 14
INTERNATIONAL ISLAMIC UNIVERSITY, ISLAMABAD
FACULTY OF BASIC & APPLIED SCIENCES
DEPARTMENT OF COMPUTER SCIENCE & SOFTWARE ENGINEERING
Page 5 of 14
INTERNATIONAL ISLAMIC UNIVERSITY, ISLAMABAD
FACULTY OF BASIC & APPLIED SCIENCES
DEPARTMENT OF COMPUTER SCIENCE & SOFTWARE ENGINEERING
Page 6 of 14
INTERNATIONAL ISLAMIC UNIVERSITY, ISLAMABAD
FACULTY OF BASIC & APPLIED SCIENCES
DEPARTMENT OF COMPUTER SCIENCE & SOFTWARE ENGINEERING
Page 7 of 14
INTERNATIONAL ISLAMIC UNIVERSITY, ISLAMABAD
FACULTY OF BASIC & APPLIED SCIENCES
DEPARTMENT OF COMPUTER SCIENCE & SOFTWARE ENGINEERING
Page 8 of 14
INTERNATIONAL ISLAMIC UNIVERSITY, ISLAMABAD
FACULTY OF BASIC & APPLIED SCIENCES
DEPARTMENT OF COMPUTER SCIENCE & SOFTWARE ENGINEERING
Q2.
package polymorphism;
import java.util.ArrayList;
import java.io.IOException;
import java.util.InputMismatchException:
import java.lang.ArrayIndexOutOfBoundsException;
import java.util.Scanner;
class Employee {
String name;
int e_no;
Employee()
{
name = "";
e_no = 0;
}
void setter(Scanner obj)
{
System.out.print("ENTER NAME OF EMPLOY: ");
name=obj.nextLine();
System.out.print("ENTER NUM OF EMPLOY: ");
e_no=obj.nextInt();
obj.nextLine();
}
void getter()
{
System.out.println("NAME: " + name);
System.out.println("EMPLOYE NO: " + e_no);
}
}
class Manager extends Employee
{
Page 9 of 14
INTERNATIONAL ISLAMIC UNIVERSITY, ISLAMABAD
FACULTY OF BASIC & APPLIED SCIENCES
DEPARTMENT OF COMPUTER SCIENCE & SOFTWARE ENGINEERING
String title;
int c_dues;
Manager()
{
title=" ";
c_dues=0;
}
@Override
void setter(Scanner obj)
{
super.setter(obj);
System.out.print("ENTER TITLE: ");
title=obj.nextLine();
System.out.print("ENTER CLUB DUES: ");
c_dues=obj.nextInt();
obj.nextLine();
}
@Override
void getter()
{
super.getter();
System.out.println("TITLE: " + title);
System.out.println("CLUB DUES: " + c_dues);
}
}
class Scientist extends Employee
{
String r_f;
int nop;
Scientist()
{
r_f=" ";
nop=0;
}
@Override
void setter(Scanner obj)
{
Page 10 of 14
INTERNATIONAL ISLAMIC UNIVERSITY, ISLAMABAD
FACULTY OF BASIC & APPLIED SCIENCES
DEPARTMENT OF COMPUTER SCIENCE & SOFTWARE ENGINEERING
super.setter(obj);
System.out.print("ENTER YOUR RESEARCH FIELD: ");
r_f=obj.nextLine();
System.out.print("ENTE NO OF PUBLICATION: ");
nop=obj.nextInt();
obj.nextLine();
}
@Override
void getter()
{
super.getter();
System.out.println("RESEARCH FIELD: " + r_f);
System.out.println("NO OF PUB: " + nop);
}
}
class Labour extends Employee
{
int wrk_hrs;
int hrs_rate;
Labour()
{
wrk_hrs=0;
hrs_rate=0;
}
@Override
void setter(Scanner obj)
{
super.setter(obj);
System.out.print("ENTER WORKING HOURS: ");
wrk_hrs = obj.nextInt();
System.out.print("ENTE HOURS RATE: ");
hrs_rate =obj.nextInt();
obj.nextLine();
Page 11 of 14
INTERNATIONAL ISLAMIC UNIVERSITY, ISLAMABAD
FACULTY OF BASIC & APPLIED SCIENCES
DEPARTMENT OF COMPUTER SCIENCE & SOFTWARE ENGINEERING
}
@Override
void getter()
{
super.getter();
System.out.println("WORKING HOURS: " + wrk_hrs);
System.out.println("HOURS RATE: " + hrs_rate);
}
}
public class PolyMorphism {
System.out.println("-----------(MENU)----------");
System.out.println("1) Manager ");
System.out.println("2) Scientist ");
System.out.println("3) Labour ");
System.out.println("4) Display All Data ");
System.out.println("5) Exit \n");
switch(ch)
Page 12 of 14
INTERNATIONAL ISLAMIC UNIVERSITY, ISLAMABAD
FACULTY OF BASIC & APPLIED SCIENCES
DEPARTMENT OF COMPUTER SCIENCE & SOFTWARE ENGINEERING
{
case '1':
emp.add(new Manager());
try
{
emp.get(n).setter(obj);
}
catch(InputMismatchException e)
{
System.out.println(e);
obj.nextLine();
System.out.println("Enter Again.......!!!! ");
emp.get(n).setter(obj);
}
n++;
break;
case '2':
emp.add(new Scientist());
try
{
emp.get(n).setter(obj);
}
catch(InputMismatchException e)
{
System.out.println(e);
obj.nextLine();
System.out.println("Enter Again.......!!!! ");
emp.get(n).setter(obj);
}
n++;
break;
case '3':
emp.add(new Labour());
try
{
emp.get(n).setter(obj);
}
catch(InputMismatchException e)
{
Page 13 of 14
INTERNATIONAL ISLAMIC UNIVERSITY, ISLAMABAD
FACULTY OF BASIC & APPLIED SCIENCES
DEPARTMENT OF COMPUTER SCIENCE & SOFTWARE ENGINEERING
System.out.println(e);
obj.nextLine();
System.out.println("Enter Again.......!!!! ");
emp.get(n).setter(obj);
}
n++;
break;
case '4':
try{
for(Employee e: emp)
e.getter();
}
catch(ArrayIndexOutOfBoundsException e)
{
System.out.println(e);
System.out.println("Acces Invalid Index.....");
}
break;
case '5':
System.exit(-1);
}
}
Page 14 of 14