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

Similar documents
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.

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.

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

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.

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.

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.

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.

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.

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.

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

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.

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.

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.

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

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

SampleApp.java. Page 1

Queen s University Faculty of Arts and Science School of Computing CISC 124 Final Examination December 2004 Instructor: M. Lamb

Give one example where you might wish to use a three dimensional array

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

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

Binghamton University. CS-140 Fall Problem Solving. Creating a class from scratch

CMP 326 Midterm Fall 2015

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

We are on the GUI fast track path

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

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

Final Examination Semester 2 / Year 2010

CSCI 201L Midterm Written Summer % of course grade

Example: Building a Java GUI

COMP16121 Sample Code Lecture 1

1.00/ Introduction to Computers and Engineering Problem Solving. Quiz 2 / November 5, 2004

Chapter 8 Objects and Classes Part 1

Example: Building a Java GUI

8. Polymorphism and Inheritance

CS-140 Fall 2017 Test 1 Version Practice Practice for Nov. 20, Name:

Overview. Lecture 7: Inheritance and GUIs. Inheritance. Example 9/30/2008

Midterm Test II Object Oriented Programming in Java Computer Science, University of Windsor Fall 2014 Time 2 hours. Answer all questions

Final Exam CS 251, Intermediate Programming December 10, 2014

Window Interfaces Using Swing Objects

Java Never Ends CHAPTER MULTITHREADING 1100 Example: A Nonresponsive GUI 1101

b. Suppose you enter input from the console, when you run the program. What is the output?

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

COMP-202 Unit 10: Basics of GUI Programming (Non examinable) (Caveat: Dan is not an expert in GUI programming, so don't take this for gospel :) )

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

Final Exam CS 251, Intermediate Programming December 13, 2017

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

This exam is closed textbook(s) and closed notes. Use of any electronic device (e.g., for computing and/or communicating) is NOT permitted.

Java Never Ends MULTITHREADING 958 Example: A Nonresponsive GUI 959

Chapter 13 Lab Advanced GUI Applications

Window Interfaces Using Swing Objects

More about GUIs GEEN163

RAIK 183H Examination 2 Solution. November 10, 2014

CSCI 201L Midterm Written SOLUTION Summer % of course grade

Final Examination Semester 2 / Year 2011

1. Which of the following is the correct expression of character 4? a. 4 b. "4" c. '\0004' d. '4'

CS 113 PRACTICE FINAL

Ryerson University Department of Electrical & Computer Engineering COE618 Midterm Examination February 26, 2013

CMP-326 Exam 2 Spring 2018 Total 120 Points Version 1

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

DAFTAR LAMPIRAN. Source Code Java Aplikasi Keyword to Image Renamer Split

Graphical User Interface

1.00/1.001 Introduction to Computers and Engineering Problem Solving Fall (total 7 pages)

CSIS 10A Assignment 7 SOLUTIONS

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

Multimedia Programming

Dr. Hikmat A. M. AbdelJaber

Chapter 13 Lab Advanced GUI Applications Lab Objectives. Introduction. Task #1 Creating a Menu with Submenus

To gain experience using GUI components and listeners.

Chapter 10 Inheritance. Big Java by Cay Horstmann Copyright 2009 by John Wiley & Sons. All rights reserved.

Queens College, CUNY Department of Computer Science. CS 212 Object-Oriented Programming in Java Practice Exam 2. CS 212 Exam 2 Study Guide

This exam is open book. Each question is worth 3 points.

CMP-326 Exam 2 Spring 2018 Solutions Question 1. Version 1. Version 2

CS1004: Intro to CS in Java, Spring 2005

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

Parts of a Contract. Contract Example. Interface as a Contract. Wednesday, January 30, 13. Postcondition. Preconditions.

Chapter 6 Introduction to Defining Classes

READ AND OBSERVE THE FOLLOWING RULES:

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

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

APPENDIX. public void cekroot() { System.out.println("nilai root : "+root.data); }

Lab 4. D0010E Object-Oriented Programming and Design. Today s lecture. GUI programming in

Lecture 3: Java Graphics & Events

Section Basic graphics

CS 349 Midterm Exam Spring 2014

Selected Questions from by Nageshwara Rao

GUI (Graphic User Interface) Programming. Part 2 (Chapter 8) Chapter Goals. Events, Event Sources, and Event Listeners. Listeners

Frames, GUI and events. Introduction to Swing Structure of Frame based applications Graphical User Interface (GUI) Events and event handling

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

UTM CSC207: Midterm Examination October 28, 2011

Final Examination Semester 2 / Year 2012

Introduction to the JAVA UI classes Advanced HCI IAT351

Transcription:

HAND IN Answers Are Recorded on Question Paper QUEEN'S UNIVERSITY SCHOOL OF COMPUTING CISC212, FALL TERM, 2006 FINAL EXAMINATION 7pm to 10pm, 19 DECEMBER 2006, Jeffrey Hall 1 st Floor Instructor: Alan McLeod If the instructor is unavailable in the examination room and if doubt exists as to the interpretation of any problem, the candidate is urged to submit with the answer paper a clear statement of any assumptions made. Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written. Please write your answers in the boxes provided. Extra space is available on page 17 of the exam. The back of any page can be used for rough work. This exam refers exclusively to the use of the Java language. Comments are not required in the code you write. For full marks, code must be efficient as well as correct. This is a closed book exam. No computers or calculators are allowed. Student Number: Problem 1: / 8 Problem 4: / 18 Problem 2: / 10 Problem 5: / 10 Problem 3: / 14 TOTAL: / 60

Student Number: Page 2 of 17 Problem 1) [4 marks for a) and 4 marks for b)] a) Provide the output of each of the following println statements, in the box beside each statement. Remember that in Java, a float can only hold a maximum of 8 significant digits, and a float literal has a capital F appended to the number. float z = 20.0F; float a = 1.0e-10F; float x = 10.0F; float b = 2.0e-10F; System.out.println(b - 2 * a + z - x); System.out.println(x + x - z - a); System.out.println(x + x - a - z); System.out.println(b - 2 * (a + z) - x); b) The two equations shown below provide one of the roots of the quadratic equation: ax 2 +bx+c = 0. They are both algebraically correct equations. Circle the equation that you would use to calculate x 1 in a Java program in the case where the product of a times c is much smaller than b. x 1 = b + 2 b 2a 4ac x 1 = b + 2c b 2 4ac Why did you choose this equation over the other? (One or two sentences only, please.)

Student Number: Page 3 of 17 Problem 3) [14 marks] You must complete an object hierarchy by writing two classes: Square and Rectangle. You are given the classes: IllegalShapeException, AllSides and a class called TestShapes that shows how your objects must work. You are also given the interface: RequiredAccessorsInterface. The hierarchy is defined by: The class Rectangle must implement RequiredAccessorsInterface. The class Square must extend Rectangle. As always, you are expected to use proper encapsulation practices. Write just the minimum amount of code required to satisfy the TestShapes class. Do not write any mutators, any other constructors than what is required, any other accessors than what is required, or any of the other standard methods, including clone(), equals(), compareto() or tostring(). An illegal dimension is less than or equal to zero. You will have space to write your two classes following this listing of the three supplied classes and the interface. public class IllegalShapeException extends Exception { public IllegalShapeException () { super("\nattempt to create an illegal shape."); // end IllegalShapeException public interface RequiredAccessorsInterface { AllSides getsides (); double getarea(); // end RequiredAccessorsInterface public class AllSides { public double side1, side2; public AllSides(double a) { side1 = a; side2 = 0; public AllSides(double a, double b) { side1 = a; side2 = b; // end AllSides

Student Number: Page 4 of 17 Problem 3, Cont.) public class TestShapes { public static void testaccessors (RequiredAccessorsInterface shape) { System.out.println("\nTesting: " + shape.getclass().getname()); System.out.println("Area = " + shape.getarea()); String s = "Side1 = " + shape.getsides().side1; if (shape.getsides().side2 > 0) s += ", Side2 = " + shape.getsides().side2; System.out.println(s); // end testaccessors public static void main(string[] args) { Square illegalsquare = null, legalsquare = null; Rectangle illegalrectangle = null, legalrectangle = null; // Square try { illegalsquare = new Square(-2.0); catch (IllegalShapeException e) { System.out.println(e.getMessage()); try { legalsquare = new Square(2.0); catch (IllegalShapeException e) { System.out.println(e.getMessage()); testaccessors(legalsquare); // Rectangle try { illegalrectangle = new Rectangle(-2.0, 3.0); catch (IllegalShapeException e) { System.out.println(e.getMessage()); try { legalrectangle = new Rectangle(2.0, 3.0); catch (IllegalShapeException e) { System.out.println(e.getMessage()); testaccessors(legalrectangle); // end main // end TestShapes

Student Number: Page 5 of 17 Problem 3, Cont.) /* Output from TestShapes: Attempt to create an illegal shape. Testing: Square Area = 4.0 Side1 = 2.0 Attempt to create an illegal shape. Testing: Rectangle Area = 6.0 Side1 = 2.0, Side2 = 3.0 */

Student Number: Page 6 of 17 Problem 3, Cont.)

Student Number: Page 7 of 17 Problem 5) [10 marks] Complete the following GUI class. You must add code to the constructor to finish the layout of the two components a label and a command button. Then you must complete the listener class so that the button causes the label to switch between two messages. The window looks like: or: Clicking on the Switch button switches the message on each click. Remember that a button s listener class must implement the ActionListener interface which will force it to have a concrete implementation of the method: public void actionperformed(actionevent e) To set the text of a label, you invoke the settext() mutator method. To add a component to a panel or a JFrame, you invoke the add() method. The listing of the class you must complete begins on the next page. Add code where indicated only, and do not change any of the supplied code. Note that you cannot get this layout by adding the button and label components directly to the frame; you must use a Container component instead (like a JPanel ).

Student Number: Page 8 of 17 Problem 5, Cont.) import javax.swing.jframe; import javax.swing.jbutton; import javax.swing.jpanel; import javax.swing.jlabel; import java.awt.font; import java.awt.borderlayout; import java.awt.event.actionevent; import java.awt.event.actionlistener; public class GUIExamProblemWindow extends JFrame { private final int WIDTH = 260; private final int HEIGHT = 140; private JButton switchmessagebutton = new JButton("Switch"); private JLabel messagelabel = new JLabel("ALMOST OVER!"); private boolean messageflag = false; public GUIExamProblemWindow () { super(); setdefaultcloseoperation(jframe.exit_on_close); settitle("gui Problem"); setsize(width, HEIGHT); messagelabel.setfont(new Font("Stencil", Font.PLAIN, 26)); switchmessagebutton.addactionlistener(new MessageButtonListener()); setlayout(new BorderLayout()); // COMPLETE THE CONSTRUCTOR HERE: // end constructor

Student Number: Page 9 of 17 Problem 5, Cont.) // WRITE THE LISTENER CLASS HERE: // end GUIExamProblemWindow class

Student Number: Page 10 of 17 (Extra page)