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

Similar documents
GROUP - A <10 questions x 4 points each = 40 points >

Java By Abstraction - Test-B (Chapters 1-6)

York University AK/ITEC OBJECT-BASED PROGRAMMING. Midterm Test Sample. Examiner: S.Y. Chen Duration: One Hour and Fifteen Minutes

York University. AP/ITEC Section M INTRODUCTION TO DATA STRUCTURES Winter Midterm Test

York University AS/AK/ITEC INTRODUCTION TO DATA STRUCTURES. Midterm Sample I. Examiner: S. Chen Duration: One Hour and 30 Minutes

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

CS Exam 1 Review Suggestions

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

Laying Out Components. What is Widget Layout?

CMP 326 Midterm Fall 2015

CS 180 Fall 2006 Exam II

What is Widget Layout? Laying Out Components. Resizing a Window. Hierarchical Widget Layout. Interior Design for GUIs

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

Midterm assessment - MAKEUP Fall 2010

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

The Islamic University Gaza Department of Electrical & Computer Engineering. Midterm Exam Spring 2012 Computer Programming II (Java) ECOM 2324

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

MIT AITI Swing Event Model Lecture 17

Final Examination Semester 2 / Year 2010

CSC 161 SPRING 17 LAB 2-1 BORDERLAYOUT, GRIDLAYOUT, AND EVENT HANDLING

Java Programming Lecture 6

Final Exam CS 251, Intermediate Programming December 13, 2017

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

Java. GUI building with the AWT

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

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

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

CS 251 Intermediate Programming GUIs: Components and Layout

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.

First Exam Computer Programming 326 Dr. St. John Lehman College City University of New York Thursday, 7 October 2010

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

8. Polymorphism and Inheritance

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

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

Resizing a Window. COSC 3461: Module 5B. What is Widget Layout? Size State Transitions. What is Widget Layout? Hierarchical Widget Layout.

Window Interfaces Using Swing Objects

PIC 20A GUI with swing

Dr. Hikmat A. M. AbdelJaber

News and info. Array. Feedback. Lab 4 is due this week. It should be easy to change the size of the game grid.

Packages: Putting Classes Together

Window Interfaces Using Swing Objects

Agenda. Container and Component

Handout 14 Graphical User Interface (GUI) with Swing, Event Handling

Java Swing. based on slides by: Walter Milner. Java Swing Walter Milner 2005: Slide 1

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

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

Java, Swing, and Eclipse: The Calculator Lab.

CSE Lab 8 Assignment Note: This is the last lab for CSE 1341

Containers and Components

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

Java Swing. Recitation 11/(20,21)/2008. CS 180 Department of Computer Science, Purdue University

SAMPLE EXAM Second Exam Computer Programming 326 Dr. St. John Lehman College City University of New York Thursday, 11 November 2010

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

Systems Programming Graphical User Interfaces

Graphical User Interfaces. Comp 152

SINGLE EVENT HANDLING

CS 209 Spring, 2006 Lab 8: GUI Development Instructor: J.G. Neal

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

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

Java Swing. Lists Trees Tables Styled Text Components Progress Indicators Component Organizers

CSI 1100 / 1500 Fall 2004 Introduction to Computer Science I Final Examination

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

Second Exam Computer Programming 326 Dr. St. John Lehman College City University of New York Thursday, 11 November 2010

Part I: Learn Common Graphics Components

Window Interfaces Using Swing. Chapter 12

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

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

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

Sample Examination Paper Programming and Software Development

Introduction to the JAVA UI classes Advanced HCI IAT351

KF5008 Program Design & Development. Lecture 1 Usability GUI Design and Implementation

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

DM503 Programming B. Peter Schneider-Kamp.

Chapter 9 Inheritance

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

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

Project 1. LibraryTest.java. Yuji Shimojo CMSC 335

AP CS Unit 11: Graphics and Events

SYSC Come to the PASS workshop with your mock exam complete. During the workshop you can work with other students to review your work.

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

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

Problem Grade Total

User interfaces and Swing

An array is a type of variable that is able to hold more than one piece of information under a single variable name.

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

McGill University School of Computer Science COMP-202A Introduction to Computing 1

JAVA. A. Zakiuddin Ahmed. M.Sc.,M.Phil M.S.(Edn), PGDCSM, Professor in Computer Science, P. Rizwan Ahmed. MCA., M.Sc.,M.A., M.Phil.

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!

Programming graphics

Mobile MOUSe JAVA2 FOR PROGRAMMERS ONLINE COURSE OUTLINE

CS Exam 3 - Spring 2010

Exam Duration: 2hrs and 30min Software Design

Graphics programming. COM6516 Object Oriented Programming and Design Adam Funk (originally Kirill Bogdanov & Mark Stevenson)

Islamic University of Gaza Faculty of Engineering Computer Engineering Department

CS 1316 Exam 3 Fall 2009

CSIS 10A Assignment 7 SOLUTIONS

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

CMSC 331 Second Midterm Exam

Transcription:

York University AS/AK/ITEC 2610 3.0 All Sections OBJECT-ORIENTED PROGRAMMING Midterm Test Duration: 90 Minutes This exam is closed textbook(s) and closed notes. Use of any electronic device (e.g., for computing and/or communicating) is NOT permitted. Do not un-staple this test book any detached sheets will be discarded. Answer all questions in the space provided. No additional sheets are permitted. (Note: a blank page has been provided at the back of this test book that you may use for rough work; do not detach it) Work independently. The value of each question is indicated. The total value of all questions is 100. Write your section letter, your name and student number in the space below. NOTE: YOU MAY USE PEN OR PENCIL, BUT ANSWERS IN PENCIL WILL NOT BE CONSIDERED FOR RE-GRADING. Section (A/B): Surname: Given Names: Student Number: A (15) B (15) C (30) D(40) Total (100) 1

Part A (15 points) Consider the following (partial) API of two classes: class Department Department(String name, int budget) Parameters: name - name of the department budget - budget of this department void assign(employee who) Parameter: who - the employee to be assigned to this department int getheadcount() Returns: the number of employees in this department int getbudget() Returns: the budget of this department void changebudget(int delta) Increase or decrease the budget of this department by the passed amount. Delta is the increment or decrement, not the new budget. Parameter: delta - change the budget by adding this amount to it (to reduce budget, provide a negative amount). class Employee Employee(String name,int rank) Parameters: name - name of the employee rank - the rank (level) of the employee Develop the Java application App whose main method performs the following tasks, in the order shown: 1. Create a department called "R&D" with budget 2,000,000. 2. Create an employee John whose rank is 3. 3. Create an employee Debbie whose rank is 2. 4. Assign both John and Debbie to the R&D department 5. Determine the head count of the R&D department by using a method, and store it in some variable count. 6. If count is greater than 10, increase the department budget by 5%, otherwise reduce it by 2%. Note that it is OK to use the above magic numbers no need to store them as constants. 2

public class App{ public static void main(string[] args){ 3

Part B (15 marks) Write the 10-lines output of the program Bird.java shown below. interface Silly { public void narf(); public void poit(silly s); public class Bird implements Silly { public static void main(string args[]) { System.out.println("zero"); Silly s = new SillyBird(1); Silly s2 = new Loony(); s.poit(s2); s2.poit(s); System.out.println("zymurgy"); public Bird() { this(0); System.out.println("zircon"); public Bird(int i) { System.out.println("zanzibar"); public void narf() { System.out.println("zort"); public void poit(silly s) { s.narf(); class SillyBird extends Bird { public SillyBird() { System.out.println("duchess"); public SillyBird(int i) { super(i); public void narf() { System.out.println("drum"); super.narf(); class Loony extends SillyBird { public Loony() { System.out.println("stupendous"); public void narf() { System.out.println("snark"); 4

5

PART C (30 marks) Multiple-Choice Questions. Circle the correct answers. Each question has only one correct answer unless specifically stated otherwise. Each question is worth 2 marks. 1) If a subclass does not explicitly call one of the superclass constructors, the default superclass constructor is called automatically. a) TRUE b) FALSE 2) Components in a GridLayout format can have different sizes. a) TRUE b) FALSE 3) Which 2 statements are true about an abstract class? (circle both) a). It can not be instantiated. b). It can not be extended. c). It can not be declared public. d). It may not have abstract methods. e). It can not be overridden. 4) Given a JLabel label and a JPanel panel with border layout, which of the following statements would you use to place the label at the top of the panel? a). panel.add(label, NORTH); b). label.add(panel, NORTH); c). panel.add(label, BorderLayout.NORTH); d). panel.add(label, BorderLayout.TOP); e). panel.add(label, TOP); 5) Which is the default LayoutManager for a JFrame? a) GridLayout b) FlowLayout c) CardLayout d) BorderLayout e) there is no default LayoutManager for a JFrame 6) In using the GridLayout, adding space between components in a container can be accomplished best by: a) including JButtons that have no names and thus will appear invisible. b) adding invisible components. c) inserting IconImages of blank images. d) specifying the spaces in pixels through the GridLayout constructor 7) In calling the method actionperformed (ActionEvent event) event is: a) an interface. b) a GUI component. c) an object. d) a listener. e) a reference to an existing object. 6

8) In order to display three components vertically in a container, you could use which 2 layout managers? (circle both) a) CardLayout b) GridLayout c) BorderLayout d) FlowLayout e) You could use any of the above. For the next 3 questions, consider the following class definition: public class AClass { protected int x; protected int y; public AClass(int a, int b){ x = a; y = b; public String tostring( ){ return x= + (++x) + \ny= + (y++) ; 9) Consider that you want to extend AClass to BClass. BClass will have a third instance data, int z. Which of the following would best define BClass' constructor? a) public BClass(int a, int b, int c){ super(a, b, c); b) public BClass(int a, int b, int c){ x = a; y = b; z = c; c) public BClass(int a, int b, int c){ z = c; d) public BClass(int a, int b, int c){ super(a, b); z = c; e) public BClass(int a, int b, int c){ super( ); 10) If the driver has the lines: BClass o = new BClass (1,2,3); System.out.println(o); the first line of the output is: 7

a) x=1 b) x=1 \n y=2 c) x=2 \n y=3 d) x=2 e) nothing 11) For the same driver the second line of output is: a) y=1 b) x=1 \n y=2 c) y=2 d) y=3 e) nothing For the next 4 questions, use the following partial class definitions: public class A{ public int x; private int y; protected int z;... public class B extends A { protected int a; private int b;... public class C extends A{ private int q;... 12) Which of the following is true with respect to classes A, B, and C? a) C is a subclass of B, and B is a subclass of A b) C and B are both subclasses of A c) A and B are both subclasses of C d) A is a subclass of B and C 13) Which of the following lists of instance variables are accessible in class B? a) x, y, z, a, b b) x, y, z, a, b, q c) x, y, z, b d) x, z, a, b e) x, z, a, q 14) Which of the following lists of instance data are accessible in class C? a) a, q b) x, y, z, a, q c) x, z, q d) z, a, q e) x, y, z, q 8

15) If you change the declaration of class C to be public class C extends B which of the following lists of instance variables are accessible in class C? a) x, y, z, a, b b) x, y, z, a, b, q c) x, y, z, b d) x, z, a, b e) x, z, a, q PART D (40 marks) Write the Java applet and the html file corresponding to the GUI shown below. The user starts by entering the results of a large number of students. For each student the user enters the name and the mark in the two textfields and then clicks on the Enter student data button. After finishing the data entry the user clicks on the other two buttons to produce the class average (truncated as an integer) and the name of the student with the highest mark. 9

10