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

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

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

CS Exam 1 Review Suggestions

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

Name Section. CS 21a Introduction to Computing I 1 st Semester Final Exam

AP CS Unit 11: Graphics and Events

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

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.

SAMPLE EXAM Exam 2 Computer Programming 230 Dr. St. John Lehman College City University of New York Thursday, 5 November 2009

1.00/1.001 Introduction to Computers and Engineering Problem Solving Final Examination - December 15, 2003

MIT AITI Swing Event Model Lecture 17

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

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

Come & Join Us at VUSTUDENTS.net

Core Java Syllabus. Pre-requisite / Target Audience: C language skills (Good to Have)

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

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

Welcome to CIS 068! 1. GUIs: JAVA Swing 2. (Streams and Files we ll not cover this in this semester, just a review) CIS 068

Packages: Putting Classes Together

PROGRAMMING DESIGN USING JAVA (ITT 303) Unit 7

CS506 Web Programming and Development Solved Subjective Questions With Reference For Final Term Lecture No 1

RAIK 183H Examination 2 Solution. November 11, 2013

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

CS 11 java track: lecture 3

1.00/1.001 Introduction to Computers and Engineering Problem Solving Final Examination - December 15, 2003

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

The Nervous Shapes Example

First Name: AITI 2004: Make-up Exam 1 July 9, Last Name:

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

Java Primer. CITS2200 Data Structures and Algorithms. Topic 2

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 :) )

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

CSE wi Final Exam 3/12/18. Name UW ID#

Final Exam May 21, 2003

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

2IS45 Programming

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

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

Starting Out with Java: From Control Structures Through Objects Sixth Edition

UNIT 3 ARRAYS, RECURSION, AND COMPLEXITY CHAPTER 11 CLASSES CONTINUED

Assoc. Prof. Dr. Marenglen Biba. (C) 2010 Pearson Education, Inc. All rights reserved.

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

RAIK 183H Examination 2 Solution. November 10, 2014

CS 180 Fall 2006 Exam II

H212 Introduction to Software Systems Honors

CSE331 Fall 2014, Final Examination December 9, 2014 Please do not turn the page until 2:30. Rules:

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

EXCEPTIONS & GUI. Errors are signals that things are beyond help. Review Session for. -Ankur Agarwal

1.00/1.001 Introduction to Computers and Engineering Problem Solving Spring Quiz 2

SINGLE EVENT HANDLING

CompSci 125 Lecture 17. GUI: Graphics, Check Boxes, Radio Buttons

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!

Syllabus & Curriculum for Certificate Course in Java. CALL: , for Queries

Contents Chapter 1 Introduction to Programming and the Java Language

Outline. Topic 9: Swing. GUIs Up to now: line-by-line programs: computer displays text user types text AWT. A. Basics

Window Interfaces Using Swing Objects

1 Looping Constructs (4 minutes, 2 points)

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

CPS122 Lecture: Graphical User Interfaces and Event-Driven Programming

Implementing Graphical User Interfaces

Objective Questions. BCA Part III Paper XIX (Java Programming) page 1 of 5

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

CS 180 Final Exam Review 12/(11, 12)/08

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

CS-140 Fall 2018 Test 2 Version A Nov. 12, Name:

Final Examination Semester 2 / Year 2011

CS 3331 Advanced Object-Oriented Programming. Final Exam

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

Syllabus for Bachelor of Technology. Computer Engineering. Subject Code: 01CE0403. B.Tech. Year - II

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

We are on the GUI fast track path

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

Java Help Files. by Peter Lavin. May 22, 2004

Assignment 2. Application Development

CS 3331 Advanced Object-Oriented Programming Final Exam

Exam 1 - (20 points)

Graphical User Interface (GUI)

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

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

Last Name: Circle One: OCW Non-OCW

Graphical User Interfaces. Swing. Jose Jesus García Rueda

protected void printserial() { System.out.println("> NO." + this.serialno); this.serialno++; }

Java Intro 3. Java Intro 3. Class Libraries and the Java API. Outline

GUI Basics. Object Orientated Programming in Java. Benjamin Kenwright

University of Cape Town Department of Computer Science. Computer Science CSC117F Solutions

About This Lecture. Data Abstraction - Interfaces and Implementations. Outline. Object Concepts. Object Class, Protocol and State.

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

Graphics User Defined Forms, Part I

Lecture 11.1 I/O Streams

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

CS Exam 3 - Spring 2010

Lab & Assignment 1. Lecture 3: ArrayList & Standard Java Graphics. Random Number Generator. Read Lab & Assignment Before Lab Wednesday!

An applet is a program written in the Java programming language that can be included in an HTML page, much in the same way an image is included in a

Object-oriented programming in Java (2)

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

CSE wi Final Exam 3/12/18 Sample Solution

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

Window Interfaces Using Swing Objects

CSE 143 Au04 Midterm 1 Page 1 of 9

Transcription:

First Name: AITI 2004: Exam 2 July 19, 2004 Last Name: JSP Track Read Instructions Carefully! This is a 3 hour closed book exam. No calculators are allowed. Please write clearly if we cannot understand your answer, you will receive 0 points for that question. This exam has 6 parts worth a total of 100 points. Section 1 Abstract Classes and Interfaces (35 points) 1. (14 points) Circle True or False True / False A class can implement several interfaces. True / False A class can be the direct subclass of several classes. True / False An interface contains a list of methods that every class which implements this interface must have. True / False You can implement methods in the body of an interface. True / False If there exists an interface called Animal, the following statement will compile successfully: Animal a1 = new Animal(); True / False If there exists an abstract class called Animal2, the following statement will compile successfully: Animal2 a2 = new Animal2(); True / False You can implement methods in the body of an abstract class. 2. (6 points) There are three Java files between the horizontal lines on the next page: Shape.java, Rectangle.java, and Square.java. Each is in a separate package. Add import statements to the files so that they compile. 3. (3 points) Implement the Square constructor on the next page. 4. (12 points) Looking at the classes on the next page, circle the output of the following code segments or circle "error" if the code would generate a compiling or execution error. Square s = new Square(3); System.out.println(s.toString()); a) square b) rectangle c) error Rectangle r = new Square(3); System.out.println(r.toString()); a) square b) rectangle c) error Shape p = new Square(3); System.out.println(p.toString()); a) square b) rectangle c) error

Square s = new Square(3); System.out.println(s.area()); a) 3 b) 9 c) error Rectangle r = new Rectangle(3, 3); System.out.println(r.area()); a) 3 b) 9 c) error Shape p = new Shape(3, 3); System.out.println(p.area()); a) 3 b) 9 c) error

package shapes; public interface Shape { public int area(); package rectangles; public abstract class Rectangle implements Shape { private int width, height; public Rectangle(int width, int height) { this.width = width; this.height = height; public int area() { return width * height; public String name() { return "rectangle"; package squares; public class Square extends Rectangle implements Shape { public Square(int size) { public String name() { return "square";

Section 2 Exceptions (12 points) 1. (4 points) Describe two differences between checked and unchecked exceptions. 2. (4 points) Change this method so that it throws an IllegalArgumentException (an unchecked exception) with an appropriate message if b is zero. public static double divide(double a, double b) { return a / b; 3. (4 points) Change this method so that it catches the IllegalArgumentException thrown by divide and prints the message "the divisor is zero" if it is thrown. public static void printquotient(double a, double b) { System.out.println(divide(a, b));

Section 3 There is NO Section 3 Section 4 IO and Parsing (12 points) 1. (2 points) In order to read/write files in Java, you should import which package? a) javax.swing b) java.util c) java.awt d) java.io 2. (2 points) To read from a character stream, you should use a class that extends which of the following abstract classes? a) InputStream b) OutputStream c) Reader d) Writer 3. (2 points) To write to a byte stream, you should use a class that extends which of the following abstract classes? a) InputStream b) OutputStream c) Reader d) Writer 4. (6 points) Complete the method sumints below. It expects a String argument containing integers separated by @ symbols and should returns the sum of those integers. For example, when passed the String "34@1@100@5", it should return 140. You can assume java.util.* has been imported. public static int sumints(string intstring) {

Section 5 Swing (21 points) 1. (2 points) In order to create graphical interfaces in Java, you should import which packages? a) java.util b) java.awt.event, javax.swing c) java.io, javax.swing d) java.util, java.swing 2. (2 points) What does the acronym GUI stand for? 3. (2 points) Which corner of your screen has the pixel coordinates (0, 0)? 4. (3 points) Name one Layout Manager and briefly describe how it lays out its components. 5. (12 points) Match the following Swing component with what it is used for: Component Use 1. JFrame A) Generated when a JButton is clicked 2. JComponent B) A top level container 3. JLabel C) Provides space for the user to type into 4. JPanel D) All the Swing components inherit from this class 5. JTextField E) An intermediate container 6. ActionEvent F) Displays text that the user cannot edit

Section 6 Inheritance and Interfaces (20 points) On the next page, you will write a hierarchy of classes to represent students in our AITI class. There should be two types of Students a JSPStudent and a StandardStudent. Both types of students should have a first name, last name. They should also both be required to contain the methods getdescription (which should return the first name, last name, and type of student for example, Samuel Mensah Standard track ). Please complete this hierarchy using abstract classes, interfaces, and/or inheritance. When you are done creating the classes, you may add a main method to one of the classes, or a new class that you create, and create a couple of students, add them to an ArrayList, and using an Iterator, print out their descriptions. Be clear when specifying where one file ends and another file begins. Make sure to include proper package statements and import statements. You may comment, but it is not necessary. However, your comments will help us to award you partial credit on your code for this problem. There are many ways to answer this question so be creative!