Throughout the exam, write concisely and underline key words or phrases. Have fun! Exam 2. Week 7 (Winter 2013). Dr. Yoder. Sec 031.

Similar documents
1. (5 points) In your own words, describe what an instance is.

SE1021 Exam 2. When returning your exam, place your note-sheet on top. Page 1: This cover. Page 2 (Multiple choice): 10pts

CSci 1103 Final. Name: Student ID:

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

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

CSSE 220 Day 19. Object-Oriented Design Files & Exceptions. Check out FilesAndExceptions from SVN

Chapter 15 Event-Driven Programming and Animations

CSSE 220 Day 19. Object-Oriented Design Files & Exceptions. Check out FilesAndExceptions from SVN

CMSC 331 Second Midterm Exam

Java Foundations. 9-1 Introduction to JavaFX. Copyright 2014, Oracle and/or its affiliates. All rights reserved.

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

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

CS 11 java track: lecture 3

2. (True/False) All methods in an interface must be declared public.

Graphical User Interface (Part-1) Supplementary Material for CPSC 233

Java Programming Lecture 7

Name: CSC143 Exam 1 1 CSC 143. Exam 1. Write also your name in the appropriate box of the scantron

Java Programming Lecture 6

Window Interfaces Using Swing Objects

Do not turn to the next page until the start of the exam.

8. Polymorphism and Inheritance

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

UMBC CMSC 331 Final Exam

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

CS 170 Java Programming 1. Week 15: Interfaces and Exceptions

Block I Unit 2. Basic Constructs in Java. AOU Beirut Computer Science M301 Block I, unit 2 1

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

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

Do not turn to the next page until the start of the exam.

CSC207 Week 4. Larry Zhang

AP COMPUTER SCIENCE JAVA CONCEPTS IV: RESERVED WORDS

Composite Pattern Diagram. Explanation. JavaFX Subclass Hierarchy, cont. JavaFX: Node. JavaFX Layout Classes. Top-Level Containers 10/12/2018

G51PGP Programming Paradigms. Lecture 009 Concurrency, exceptions

Module Contact: Dr Gavin Cawley, CMP Copyright of the University of East Anglia Version 1

Midterm assessment - MAKEUP Fall 2010

COSC 123 Computer Creativity. I/O Streams and Exceptions. Dr. Ramon Lawrence University of British Columbia Okanagan

Check out FilesAndExceptions from SVN. Exam 2 Review File I/O, Exceptions Vector Graphics Project

Introduction to Programming Using Java (98-388)

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

Lecture 28. Exceptions and Inner Classes. Goals. We are going to talk in more detail about two advanced Java features:

CS 251, Intermediate Programming Midterm Exam October 9, 2013

Association, Aggregation and Composition. Software Engineering CITS1220

Object Oriented Programming 2015/16. Final Exam June 17, 2016

Agenda CS121/IS223. Reminder. Object Declaration, Creation, Assignment. What is Going On? Variables in Java

abstract binary class composition diamond Error Exception executable extends friend generic hash implementation implements

Programming Languages and Techniques (CIS120)

CS 112 Programming 2. Lecture 14. Event-Driven Programming & Animations (1) Chapter 15 Event-Driven Programming and Animations

Window Interfaces Using Swing Objects

Event-Driven Programming with GUIs. Slides derived (or copied) from slides created by Rick Mercer for CSc 335

Prelim 1. CS 2110, September 29, 2016, 7:30 PM Total Question Name Loop invariants

We are on the GUI fast track path

Java Programming. Events and Listeners

CS121/IS223. Object Reference Variables. Dr Olly Gotel

Final Exam CS 251, Intermediate Programming December 10, 2014

CSCE 145 Exam 2 Review No Answers. This exam totals to 100 points. Follow the instructions. Good luck!

Exceptions and Libraries

PART ONE CREATING THE BOARD AND MAIN SPRITES

Come & Join Us at VUSTUDENTS.net

Programming Languages and Techniques (CIS120)

The JFrame Class Frame Windows GRAPHICAL USER INTERFACES. Five steps to displaying a frame: 1) Construct an object of the JFrame class

+! Today. Lecture 3: ArrayList & Standard Java Graphics 1/26/14! n Reading. n Objectives. n Reminders. n Standard Java Graphics (on course webpage)

CS Exam 1 Review Suggestions

CS 170 Java Programming 1. Week 9: Learning about Loops

M257 Past Paper Oct 2008 Attempted Solution

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

Java for Non Majors. Final Study Guide. April 26, You will have an opportunity to earn 20 extra credit points.

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

CS56 final (E03) W15, Phill Conrad, UC Santa Barbara Wednesday, 03/18/2015. Name: Umail umail.ucsb.edu. Circle one: 4pm 5pm 6pm

Prelim 1 SOLUTION. CS 2110, September 29, 2016, 7:30 PM Total Question Name Loop invariants. Recursion OO Short answer

Global Gomoku Lab 4 in D0010E

CSE 501N Final Fall Points Possible

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

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

GUI DYNAMICS Lecture July 26 CS2110 Summer 2011

Standard. Number of Correlations

COMP-202 Unit 9: Exceptions

Exception-Handling Overview

Virtualians.ning.pk. 2 - Java program code is compiled into form called 1. Machine code 2. native Code 3. Byte Code (From Lectuer # 2) 4.

CSCI 201L Midterm Written SOLUTION Fall % of course grade

Object Oriented Programming 2015/16. Final Exam June 28, 2016

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

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

CS 2334: Programming Structures and Abstractions: Exam 1 October 3, 2016

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

OLLSCOIL NA héireann THE NATIONAL UNIVERSITY OF IRELAND COLÁISTE NA hollscoile, CORCAIGH UNIVERSITY COLLEGE, CORK. Summer Examination 2012

Java Object Oriented Design. CSC207 Fall 2014

Framework. Set of cooperating classes/interfaces. Example: Swing package is framework for problem domain of GUI programming

CS 61B Data Structures and Programming Methodology. July 7, 2008 David Sun

Graphical User Interface (GUI)

2.6 Error, exception and event handling

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

Chapter 12 Exception Handling

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

CS115. Chapter 17 Exception Handling. Prof. Joe X. Zhou Department of Computer Science. To know what is exception and what is exception handling

Topic 9: Swing. Swing is a BIG library Goal: cover basics give you concepts & tools for learning more

Topic 9: Swing. Why are we studying Swing? GUIs Up to now: line-by-line programs: computer displays text user types text. Outline. 1. Useful & fun!

GUI Event Handlers (Part I)

Declarations and Access Control SCJP tips

Object-oriented programming in Java (2)

Implementing Graphical User Interfaces

Transcription:

SE1021 Exam 2 Name: You may have an 8.5x11 note sheet for this exam. No calculators or other study aids on this exam. Write your initials at the tops of the following pages and read through the exam before you get started. Throughout the exam, write concisely and underline key words or phrases. Have fun! Exam 2. Week 7 (Winter 2013). Dr. Yoder. Sec 031. Page 1 of 7

1. (5 points) In your own words, describe what an instance is. Name: 2. (5 points) Consider the Apple class in the UML diagram on the right. Write a couple lines of code to call the instance method getcolor() from outside of the Apple class. Declare all variables that you use. 3. (5 points) Write two differences between an abstract class and an interface. 4. (5 points) Name two Java classes/interfaces one whose instances are event sources, and one whose instances are event listenershandlers. 5. (5 points) JavaFX Swing provides a framework for responding to user actions. When a button is pressed, some of your code should be run. Describe how the framework determines what code to run. (I don t expect you to need the space below this line.) Exam 2. Week 7 (Winter 2013). Dr. Yoder. Sec 031. Page 2 of 7

Name: 6. Consider the program below try { Scanner in = new Scanner(System.in); System.out.print("Enter the number of pixels in the image: "); int size = in.nextint(); System.out.print("Enter the number of pixels in a row: "); int width = in.nextint(); int height = size/width; System.out.println("h: "+height); } catch (InputMismatchException e) { System.out.println("ime"); } finally { System.out.println("f"); } System.out.println("done"); If something other than a number is entered, in.nextint() throws an InputMismatchException. Omitting the prompts to the user and exception stack traces, write what will be printed if. a. (5 points) The user enters 100 and 10 b. (5 points) The user enters 100 and 0 c. (5 points) The user enters 100 and qwert 7. (5 points) Describe the difference between an Error and an Exception 8. (5 points) Describe the difference between an Exception and a RuntimeException Exam 2. Week 7 (Winter 2013). Dr. Yoder. Sec 031. Page 3 of 7

Name: 9. (17 points 2 points for each multiple choice, 1 point for the true/false.) Consider the UML diagram for the program below. This program is similar to the one on Exam 1, but there are several key differences. a. Select one. The relationship between Work and Book is i. Composition ii. Aggregation iii. Inner-class iv. Inheritance v. Implementation b. Select one. The relationship between Library and Shelf is i. Composition ii. Aggregation iii. Inner-class iv. Inheritance v. Implementation c. Select one. The relationship between HasGraphic and Painting is i. Composition ii. Aggregation iii. Inner-class iv. Inheritance v. Implementation d. Select one. As indicated on the diagram, the tostring method of Work is i. abstract ii. volatile iii. void iv. static v. final e. Select one. As indicated on the diagram, the title variable of Work is i. abstract ii. volatile iii. void iv. static v. final Exam 2. Week 7 (Winter 2013). Dr. Yoder. Sec 031. Page 4 of 7

Name: (continued from previous page see figure there) f. Select one. Which of the following statements is valid? i. Book b = new Book(); ii. Work w = new Book("John Hancock","Declaration of Independence"); iii. Book b = new Work(); iv. Work w = new Work("My Masterpiece"); g. Select one. Which of the following statements is valid if lib is a Library? i. lib.add(new Book()); ii. lib.add(new Shelf("Top shelf")); iii. lib.add(new Book( Dean & Dean","Java")); iv. lib.add(new Shelf()); h. Circle one: true / false: A shelf can contain more than one book. i. Select one. (Unrelated to the diagram on the previous page.) Which layout manager pane would be best for designing this layout: Each button follows the one right before it. i. FlowLayoutFlowPane ii. BorderLayoutVBox iii. BoxLayoutHBox iv. GridLayoutTilePane 10. (8 points) Considering the UML diagram from Problem 5 9, write the entire add method for the Library. (The Library s constructor takes a numshelves argument. This is the initial number of shelves and is not intended to limit the total number of shelves that the Library has,) Exam 2. Week 7 (Winter 2013). Dr. Yoder. Sec 031. Page 5 of 7

Initials: 11. (5 points) Consider this code-snippet. public class Gui extends JFrame Application { private String title; @Override public void start(stage primarystage) { public JFrame() { JButton b = new Button("Press me"); b.addactionlistenersetonaction(e->system.out.println(title)); } } Write whether or not it is legal for the lambda expression above to access the instance variable title, and explain your answer. 12. (10 points) Write an anonymous inner class implementing the EventHandler<ActionEvent>ActionListener interface. This interface contains one method: public void handle(actionevent event)void actionperformed(actionevent e);. Your handler action listener should set the text of the variable textlabel to "hi" when it is called. Assign the variable a to point to an instance of your anonymous inner class. Formatted: Consolas Char Formatted: Consolas Char 13. (5 points) Consider an ActionHanlderActionListener that listens to handles multiple buttons. Describe one technique the action listener handler could use to determine which button was clicked. 14. (5 points) Suppose you call a method that throws a FileNotFoundException, a checked exception. Describe the consequences of not catching this exception with a try-catch block. Week 7, Winter 2014-2015. Dr. Yoder. 6 of 7

Initials: Week 7, Winter 2014-2015. Dr. Yoder. 7 of 7