You are on page 1of 6

KOHAT UNIVERSITY OF SCIENCE & TECHNOLOGY

INSTITUTE OF INFORMATION TECHNOLOGY


CS453 – Object Orienetd Analysis and Design
Course Instructor: Qadeem Khan
Program: BSCS Mid Term Exam (Open Book) Semester: Spring-2021
Max Marks: 30 Max Time Allowed: 24 hrs.

INSTRUCTIONS:
• Make sure to type in the correct/complete registration number and full name.
• In case of any query, the candidates can contact their course instructor on 033329032320 or
m.qadeem@kust.edu.pk. However, only text/WhatsApp messages will be allowed. To ensure
transparency, no voice calls are permissible.
• Attempt all questions.
• This is an open book exam; therefore, the candidates are allowed to use any book, tool, or internet
resource.
• The candidates can type in the answer and also allowed to write the answer on a paper and get its
scan(photo) attached.
• All the answers will be strictly checked for plagiarism. Any copied/matched answer will be considered as
null and void.
• For code, it must be executable; no syntax/typo mistakes are acceptable.
• In case of multiple attempts, only the first submitted solved paper will be considered.
• The exam will be opened on the prescribed time for a specific period and will be closed after the lapse of
time. Any late submission will not be entertained.
• For drawing figures, software tools like MS Visio and Visual Paradigm, etc. can be used. After creating
the diagrams in such tools must be pasted at appropriate places in the document.
• The given spaces for answers can be shrunk or expanded.
• The actual exam duration is 1-3 hrs. However, to cover any mishap additional time is given. Therefore,
any excuse for late submission or non-submission is not acceptable.
• All the students must submit in PDF Format

Registration Number:

Name and Section:

TO BE FILLED BY THE INSTRUCTOR:

Question# Q1 Q2 Q3 Q4 Q5 Q6 Q7 Q8 Q9 Q10 TOTAL


Marks 5 5 5 5 5 5 - - - - 30
Obtained
Marks

MID EXAM: BSCS 6th Semester Page 1 of 4 Institute of computing


Object Orineted Analysis and Design (CS 453) Kohat University of Science & Technology
SECTION A: Structural UML
(15 marks)

Consiser the following code of Java.

publicclassCelciusReporter {
doubletemperatureInC;
publicCelciusReporter() {
}
publicdoublegetTemperature() {
returntemperatureInC;
}
publicvoidsetTemperature(doubletemperatureInC) {
this.temperatureInC = temperatureInC;
}
}
publicinterfaceTemperatureInfo {
publicdoublegetTemperatureInF();
publicvoidsetTemperatureInF(doubletemperatureInF);
publicdoublegetTemperatureInC();
publicvoidsetTemperatureInC(doubletemperatureInC);
}
publicclassTemperatureObjectReporterimplementsTemperatureInfo {
CelciusReportercelciusReporter;
publicTemperatureObjectReporter() {
celciusReporter = newCelciusReporter();
}
@Override
publicdoublegetTemperatureInC() {
returncelciusReporter.getTemperature();
}
@Override
publicdoublegetTemperatureInF() {
returncToF(celciusReporter.getTemperature());
}
@Override
publicvoidsetTemperatureInC(doubletemperatureInC) {
celciusReporter.setTemperature(temperatureInC);
}
@Override
publicvoidsetTemperatureInF(doubletemperatureInF) {
celciusReporter.setTemperature(fToC(temperatureInF));
}
privatedoublefToC(double f) {
return ((f - 32) * 5 / 9);
}
privatedoublecToF(double c) {
return ((c * 9 / 5) + 32);
}
}

MID EXAM: BSCS 6th Semester Page 2 of 4 Institute of computing


Object Orineted Analysis and Design (CS 453) Kohat University of Science & Technology
publicclass Demo {

publicstaticvoid main(String[] args) {


System.out.println("\n test demo");
TemperatureInfotempInfo = newTemperatureObjectReporter();
testTempInfo(tempInfo);
}
publicstaticvoidtestTempInfo(TemperatureInfotempInfo) {
tempInfo.setTemperatureInC(0);
System.out.println("temp in C:" + tempInfo.getTemperatureInC());
System.out.println("temp in F:" + tempInfo.getTemperatureInF());

tempInfo.setTemperatureInF(85);
System.out.println("temp in C:" + tempInfo.getTemperatureInC());
System.out.println("temp in F:" + tempInfo.getTemperatureInF());
}
}

Question 1: Reverse Engineer (Create) the UML Class Diagram from the code?

Question 2: Create Sequence Diagram of the execution of main( ) method ?

Question 3: Categorize the following relationships into generalization, aggregation or


association. Justify your answer? (5 Marks)

a) A country has a capital city.


b) A file is an ordinary file or a directory file.
c) Files contain records.
d) A polygon is composed of an ordered set of points.
e) A drawing object is text, a geometrical object, or a group.

MID EXAM: BSCS 6th Semester Page 3 of 4 Institute of computing


Object Orineted Analysis and Design (CS 453) Kohat University of Science & Technology
f) A route connects two cities.
g) A student takes a course from a professor.

SECTION B: Behavioral UML


(5 marks)

Question 4: Create Activity Diagram of the following case study ?

A soft drink vending machine accepts coins for a variety of products. When the
amount of money deposited into the machine is equal to or greater than the price of
any of its available products, the respective product selection buttons will be
enabled for the user to make the selection. After the user has made a valid
selection, the machine will dispense the soft drink, together with the change (if
applicable). (5 Marks)

MID EXAM: BSCS 6th Semester Page 4 of 4 Institute of computing


Object Orineted Analysis and Design (CS 453) Kohat University of Science & Technology
SECTION C: Java Programming (10 marks)

Question 5: Write the complete code for the following class diagram. The main part is to implement the
proper relationship in java. Leave the opeations as empty and dummy ?

MID EXAM: BSCS 6th Semester Page 5 of 4 Institute of computing


Object Orineted Analysis and Design (CS 453) Kohat University of Science & Technology
Question 6: Write the complete code for the following output in the java language. Also create the
package diagram of UML as the program containing the built-in packages? ? (5 Marks)

MID EXAM: BSCS 6th Semester Page 6 of 4 Institute of computing


Object Orineted Analysis and Design (CS 453) Kohat University of Science & Technology

You might also like