Object-Oriented Software Engineering (Re-exam for Object-Oriented Analysis, Design and Programming)

Similar documents
Multimedia Programming

Object-Oriented Software Engineering Re-exam, 2012 (Also Object-Oriented Analysis, Design and Programming, Re-exam, 2012)

7. Sketch mode: Description of system for communicating specific information to humans that leaves out many details that are not required.

Object- Oriented Analysis, Design and Programming

Object- Oriented Analysis, Design and Programming. Instructions. Medialogy, 4 th Semester, Aalborg. Tuesday 30 August 2011,

OOADP/OOSE Re- exam. 23 August Mapping marks onto grades. Answers

Systems Programming. Bachelor in Telecommunication Technology Engineering Bachelor in Communication System Engineering Carlos III University of Madrid

Object- Oriented Analysis, Design and Programming

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.

Midterm assessment - MAKEUP Fall 2010

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.

PART1: Choose the correct answer and write it on the answer sheet:

Goals. Lecture 7 More GUI programming. The application. The application D&D 12. CompSci 230: Semester JFrame subclass: ListOWords

Exam Duration: 2hrs and 30min Software Design

Network Programming. Powered by Pentalog. by Vlad Costel Ungureanu for Learn Stuff

Page 1 of 16. Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.

F I N A L E X A M I N A T I O N

CS 2113 Software Engineering

Page 1 of 16. Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.

Chapter 2. Network Chat

CSCI 136 Written Exam #1 Fundamentals of Computer Science II Spring 2015

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.

COMP 213. Advanced Object-oriented Programming. Lecture 20. Network Programming

First Name: AITI 2004: Exam 2 July 19, 2004

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.

CS108, Stanford Handout #22. Thread 3 GUI

1 Looping Constructs (4 minutes, 2 points)

CPSC 441 Tutorial TCP Server. Department of Computer Science University of Calgary

Software component interactions and sequence diagrams

CSCI 201L Midterm Written Summer % of course grade

protocols September 15,

Answer on question #61311, Programming & Computer Science / Java

Lab 1 : Java Sockets

Network. Dr. Jens Bennedsen, Aarhus University, School of Engineering Aarhus, Denmark

CS 5010: PDP. Lecture 11: Networks CS 5010 Fall 2017 Seattle. Adrienne Slaughter, Ph.D.

CSCI 201L Midterm Written SOLUTION Summer % of course grade

Graphical User Interface

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.

Multiple Choice Questions: Identify the choice that best completes the statement or answers the question. (15 marks)

First Name: AITI 2004: Exam 2 July 19, 2004

THIS EXAMINATION PAPER MUST NOT BE REMOVED FROM THE EXAMINATION ROOM

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.

Distributed Programming - Sockets

G51PGP Programming Paradigms. Lecture 009 Concurrency, exceptions

INTRODUCTION TO SOFTWARE SYSTEMS (COMP1110/COMP1140/COMP1510/COMP6710)

CS 51 Laboratory # 12

M257 Putting Java to work

CS 101 Exam 1 Spring 200 Id Name

More about GUIs GEEN163

CSCI 136 Written Exam #1 Fundamentals of Computer Science II Spring 2012

UTM CSC207: Midterm Examination October 28, 2011

CMP 326 Midterm Fall 2015

"protocol stack! chat. Java

CS September 2017

Building a GUI in Java with Swing. CITS1001 extension notes Rachel Cardell-Oliver

Input from Files. Buffered Reader

CONTENTS. Chapter 1 Getting Started with Java SE 6 1. Chapter 2 Exploring Variables, Data Types, Operators and Arrays 13

Pieter van den Hombergh Richard van den Ham. March 17, 2018

17 GUI API: Container 18 Hello world with a GUI 19 GUI API: JLabel 20 GUI API: Container: add() 21 Hello world with a GUI 22 GUI API: JFrame: setdefau

CSCI 136 Written Exam #1 Fundamentals of Computer Science II Spring 2012

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.

SampleApp.java. Page 1

RAIK 183H Examination 2 Solution. November 10, 2014

Question Points Score Total 100

Course Status Networking GUI Wrap-up. CS Java. Introduction to Java. Andy Mroczkowski

Hanley s Survival Guide for Visual Applications with NetBeans 2.0 Last Updated: 5/20/2015 TABLE OF CONTENTS

I pledge by honor that I will not discuss this exam with anyone until my instructor reviews the exam in the class.

Java Support for developing TCP Network Based Programs

RAIK 183H Examination 2 Solution. November 11, 2013

CSCI 201L Written Exam #1 - SOLUTION Fall % of course grade

Networking Basics. network communication.

CSCI 136 Written Exam #2 Fundamentals of Computer Science II Spring 2015

Review sheet for Final Exam (List of objectives for this course)

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.

Final Examination Semester 3 / Year 2008

OBJECT ORIENTED PROGRAMMING. Course 6 Loredana STANCIU Room B616

Instruction to students:

CSCI 201L Written Exam #1 Fall % of course grade

CSCD 330 Network Programming Spring 2018

University of Cape Town ~ Department of Computer Science Computer Science 1015F ~ June Exam

M257 Past Paper Oct 2008 Attempted Solution

Internet Technology 2/7/2013

JRadioButton account_type_radio_button2 = new JRadioButton("Current"); ButtonGroup account_type_button_group = new ButtonGroup();

Final Examination Semester 2 / Year 2012

READ AND OBSERVE THE FOLLOWING RULES:

CSE 131 Introduction to Computer Science Fall Final Exam

Final Exam. Name: Student ID Number: Signature:

COMP16121 Sample Code Lecture 1

I. True/False: (2 points each)

CS 351 Design of Large Programs Sockets Example

School of Informatics, University of Edinburgh

URL Kullanımı Get URL

Networking Code CSCI 201 Principles of Software Development

Introduction This assignment will ask that you write a simple graphical user interface (GUI).

General Certificate of Education Advanced Subsidiary Examination June 2010

CSci 1103 Final. Name: Student ID:

IT 1003 Introduction to Programming (New)

CS 355. Computer Networking. Wei Lu, Ph.D., P.Eng.

Java Never Ends Multithreading Networking with Stream Sockets JavaBeans Java and Database Connections 1106

Transcription:

Object-Oriented Software Engineering (Re-exam for Object-Oriented Analysis, Design and Programming) Medialogy, 4 th Semester, Aalborg Monday 11 June 2012, 09.00 12.00 Instructions You have 3 hours to complete this examination. Neither written material nor electronic equipment may be brought into the examination room. There are 24 questions and each question is worth 5 marks. The maximum possible score is 120 marks. You must get at least 50 marks to pass. The following table shows the grade that will be awarded for a given number of marks: No. of Marks Grade 0 24-3 25 49 00 50 59 02 60 69 4 70 79 7 80 89 10 90 120 12 Note that a number at the beginning of any line in a program listing indicates the number of that line and is not part of the program itself. DO NOT UNTIL INSTRUCTED TO DO SO! 1

Question 1 Which one of the following was the main cause of failure in the Ariane 5 project? A. Software inflexible and difficult to maintain. B. Software re-used without thoroughly testing its operation in the new context. C. Chose to build an expensive new system instead of modifying an existing one. D. Software interlocks did not prevent a dangerous configuration. Question 2 Which one of the following was one of the main problems in the Taurus project? A. Software inflexible and difficult to maintain. B. Software re-used without thoroughly testing its operation in the new context. C. Chose to build an expensive new system instead of modifying an existing one. D. Software interlocks did not prevent a dangerous configuration. Question 3 Write down the output of the following Java program. public class WhileLoop { int i = 0; while (i < 5) { System.out.println(i); i++; Question 4 Write down the output of the following Java program. public class CondPercent { double x = -1.0; do { System.out.print(x % -1); if (x % 1 == 0) System.out.println(" int"); else System.out.println(" float"); x +=.5; while (x < 1); 2

Question 5 Grady Booch defined an object to be a thing that has behaviour, state and identity. Explain what the terms thing, behaviour, state and identity mean in this context. Question 6 The following UML class diagram shows three classes. Use inheritance to refactor the three classes so that each attribute is defined in exactly one place. Represent the refactored structure using a UML class diagram. name age weight length wingspan Parrot Horse name age weight length height foreleglength hindleglength Elephant name age weight length height foreleglength hindleglength trunklength tusklength Question 7 Name and briefly describe the three modes of using UML. Question 8 What is the noun identification technique and what is it used for? Briefly state the steps involved in applying it. Question 9 Study the following UML class diagram and answer the questions that follow it. LibraryMember 0..1 0..1 borrows reserves 0..* 0..* Copy 1..* is a copy of 1 Book a. How many Copy objects are there associated with one Book object? b. According to the diagram, is it possible for the same Copy object to be both borrowed and reserved simultaneously? c. How many Books can each library member borrow? Explain your answer. d. How many LibraryMember objects are there associated with each Copy object? 3

Question 10 Study the following UML class diagram and answer the questions that follow it. Student 0..* 12..* Course is taking mark : Integer year : Integer a. What does the box labelled is taking represent? b. If a student takes a course twice, how can the two results that the student obtains be represented using this class model? c. Draw a diagram that represents another class model for representing the results that students obtain on courses, which uses only normal associations between classes. Does this model have any advantages over the model drawn above? Question 11 Write down the output of the following Java program. public class Integers { static class Ints { int value = 0; int x, y; Ints p = new Ints(), q = new Ints(); x = 3; y = x; x = 4; System.out.println(y); p.value = 3; q = p; p.value = 4; System.out.println(q.value); 4

Question 12 Write down the output of the following Java program. public class Inheritance { static class Point { int x, y; public String tostring() { return "("+x+","+y+")"; static class ThreeDPoint extends Point { int z; public String tostring() { return "("+x+","+y+","+z+")"; Point p = new Point(); Point t = new ThreeDPoint(); System.out.println(p); System.out.println(t); Question 13 Study the following Java program. 1 public class Q13 { 2 public int add(int x, int y) { 3 return x + y; 4 5 6 7 System.out.println(add(2,3)); 8 9 This program will not compile because there is an error in one line. Give the line number of the line that contains the error and write down what this line should be in order for the program to generate the following output: 5 5

Question 14 Write down the output of the following Java program. import java.util.arraylist; import java.util.treeset; public class Collections { ArrayList<Integer> a = new ArrayList<Integer>(); TreeSet<Integer> t = new TreeSet<Integer>(); for(int i = 0; i < 5; i++) { a.add(i%3); t.add(i%3); System.out.println(a); System.out.println(t); Question 15 Study the following sequence diagram and answer the questions that follow it. : BookBorrower thelibrarymember :LibraryMember thecopy :Copy thebook :Book borrow(thecopy) oktoborrow() canborrow = oktoborrow() opt [canborrow == true] beborrowed(thelibrarymember) copyborrowed(thecopy) a. What kind of message does the arrow labelled borrow(thecopy) represent? b. What does the arrow labelled canborrow = oktoborrow() represent? c. What is the type of the value returned by oktoborrow()? d. To which class does the borrow method belong? e. To which class does the beborrowed method belong? 6

Question 16 Study the following sequence diagram and answer the questions that follow it. a. What kind of thing is Student? b. What kind of message is represented by the arrow labelled sendemail? c. To which class does the choosecourses method belong? d. To which class does the confirmchoice method belong? e. To what kind of object does the argument self refer in the call to confirmchoice? Question 17 Study the following state machine diagram, which represents the various states of a hardware-setup wizard, and answer the questions that follow it. Update hardware window search Searching do/ search for new hardware Display new hardware window cancel a. If the system successfully finds new hardware and finishes searching for it, what happens then? b. What causes the system to transition from the Update hardware window state to the Searching state? c. Under what conditions does the system exit the Searching state and to which new state does it transition under each condition? d. Does do/ indicate an action or an event? e. Are search and cancel actions or events? 7

Question 18 Study the following UML diagram and answer the questions that follow it. a. What kind of diagram is this? b. What kind of thing is the icon labelled Two hours before flight? What is its function in the diagram? c. What kind of thing is the vertical bar to the left of the box labelled Leave for airport? How does this element function in the diagram? d. What kind of thing is the box labelled Taxi arrives? How does this element function in the diagram? Question 19 Explain, with an example, what is meant by the race condition in multi-threaded programming. 8

Question 20 Study the following Java program and answer the questions that follow it. 1 public class Threads { 2 public static Integer balance = 100; 3 4 static class ChangeRunnable implements Runnable { 5 int x; 6 7 ChangeRunnable(int x) { 8 this.x = x; 9 10 11 public void run() { 12 try{ 13 Thread.sleep((long)Math.random()*1000); 14 int b = balance; 15 Thread.sleep((long)Math.random()*1000); 16 b += x; 17 Thread.sleep((long)Math.random()*1000); 18 balance = b; 19 catch(exception e) { 20 e.printstacktrace(); 21 22 23 24 25 26 try { 27 Thread plus10 = new Thread(new ChangeRunnable(10)); 28 Thread minus5 = new Thread(new ChangeRunnable(-5)); 29 plus10.start(); 30 minus5.start(); 31 plus10.join(); 32 minus5.join(); 33 System.out.println(balance); 34 catch (InterruptedException e) { 35 e.printstacktrace(); 36 37 38 a. What are the possible outputs of this program? b. How would you modify the program so that it always generates the same output every time it is run? c. Discuss whether this modified version of the program should be considered multithreaded. 9

Question 21 Explain the difference between UDP and TCP. Which protocol would you use for each of the following applications: a. A time server. b. FTP c. ping Question 22 Suppose we have two Java programs, Client and Server. The Server program is defined as follows: import java.io.bufferedreader; import java.io.inputstreamreader; import java.io.printwriter; import java.net.serversocket; import java.net.socket; public class Server { try { ServerSocket serversocket = new ServerSocket(50000); Socket clientsocket = serversocket.accept(); PrintWriter out = new PrintWriter(clientSocket.getOutputStream(), true); BufferedReader in = new BufferedReader(new InputStreamReader(clientSocket.getInputStream())); String line = in.readline(); System.out.println(line); out.println(line+" to you too!"); out.close(); in.close(); clientsocket.close(); serversocket.close(); catch (Exception e) { e.printstacktrace(); 10

The Client program is defined as follows: import java.io.bufferedreader; import java.io.inputstreamreader; import java.io.printwriter; import java.net.socket; public class Client { try { Socket socket = new Socket("localhost",50000); PrintWriter out = new PrintWriter(socket.getOutputStream(),true); BufferedReader in = new BufferedReader(new InputStreamReader(socket.getInputStream())); out.println("hello"); System.out.println(in.readLine()); out.close(); in.close(); socket.close(); catch (Exception e) { e.printstacktrace(); a. When running this system, which of the two programs should be started first? b. What is printed out to the console window by the Server program? c. What is printed out to the console window by the Client program? d. Explain the difference between a BufferedReader, an InputStreamReader and an InputStream. e. To what does the number 50000 refer in the first line of the try block in each program? Question 23 Name the three different types of thread used in a Swing program and briefly describe the function of each. 11

Question 24 Study the following Java program and answer the questions that follow it. 1 import java.awt.borderlayout; 2 import java.awt.event.actionevent; 3 import java.awt.event.actionlistener; 4 import javax.swing.jframe; 5 import javax.swing.jlabel; 6 import javax.swing.jtextfield; 7 import javax.swing.swingutilities; 8 9 public class GUI extends JFrame implements ActionListener { 10 11 private static final long serialversionuid = 1L; 12 private JTextField text = new JTextField(); 13 private JLabel label = new JLabel(); 14 15 public GUI() { 16 settitle("gui"); 17 setdefaultcloseoperation(jframe.exit_on_close); 18 getcontentpane().add(text); 19 getcontentpane().add(label,borderlayout.line_start); 20 text.addactionlistener(this); 21 pack(); 22 setvisible(true); 23 24 25 public void actionperformed(actionevent event) { 26 label.settext("text: "+text.gettext()); 27 28 29 30 SwingUtilities.invokeLater(new Runnable() { 31 public void run() { 32 new GUI(); 33 34 ); 35 36 a. What kind of layout manager does the program use? Briefly describe how this type of layout manager behaves. b. Give the variable name and type of each component that appears in the GUI. c. Which object in the program serves as an ActionListener? d. What does this ActionListener do? e. What does the statement, pack(), do in the sixth line of the constructor? END OF EXAMINATION 12