You are on page 1of 14

INTERNATIONAL ISLAMIC UNIVERSITY, ISLAMABAD

FACULTY OF BASIC & APPLIED SCIENCES


DEPARTMENT OF COMPUTER SCIENCE & SOFTWARE ENGINEERING

Mid Term Examinations, Fall 2020


COURSE TITLE Computer Communication COURSE CODE CS-372
Networks
PROGRAM BS (Supervisory) BATCH Miscellaneous
TOTAL MARKS 40 DATE & TIME 03-Dec-2020 6 p.m.
CREDIT HOURS 03 TEACHER NAME Majid Bashir

Q. No. Marks Obtained


1
2
Mid-term Marks out of 40

Student Name: Muhammad Ahmer


Reg#: 3961 fbas bscs f 18 b

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

4. How to submit(upload) your answer-booklet/paper:


After completing your answers, you need to:
a. Mention/write your Name and Registration Number, Page number and sign on each
page of your handwritten answer-sheet.
b. Take pictures using mobile camera or Scan each page of your written answers /answer
sheets via any scanning software (as guided in the video tutorial).
c. Insert all pictures or scanned images of your answer sheets into the MS word file titled as
“<Name of the Course>_Answer-Booklet.docx” provided by the teacher in the Google
Classroom.
d. After inserting all the images, save the “<Name of the course>_Answer-Booklet.docx”
file as a single PDF file (Only PDF format is acceptable as your answer-booklet), and
upload it in the Google Forms (link of which is provided in the Google Classroom).
e. Please make sure you upload the correct document as you will not be able to change this,
once it has been submitted.
(Please see the video tutorial regarding procedure to upload the examination responses,
shared in the Google classroom).

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.”

Student’s Affirmation: I affirm the given pledge ☐

[Start Inserting Images on Page No. 3]

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.

Insert Pictures of Answer Sheet Here

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 {

public static void main(String[] args) {


Scanner obj=new Scanner(System.in);

ArrayList<Employee> emp = new ArrayList<Employee>();


int n = 0;
while(true)
{

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");

System.out.print("Enter Your Choice: ");


char ch = obj.next().charAt(0);
obj.nextLine();

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

You might also like