Fall, 2013 CIT 590. Programming Languages and Techniques Final - 2 hrs

Similar documents
CIT Special final examination

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

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

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

Final Examination Semester 2 / Year 2010

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

Systems Programming Graphical User Interfaces

CIS 120 Programming Languages and Techniques. Final Exam, May 3, 2011

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 455 Midterm Exam 1 Fall 2016 [Bono] Thursday, Sept. 29, 2016

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

CS 1316 Exam 3 Fall 2009

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

Final Exam CS 251, Intermediate Programming December 13, 2017

Calculator Class. /** * Create a new calculator and show it. */ public Calculator() { engine = new CalcEngine(); gui = new UserInterface(engine); }

CS201 - Assignment 3, Part 1 Due: Friday February 28, at the beginning of class

Software Testing Prof. Meenakshi D Souza Department of Computer Science and Engineering International Institute of Information Technology, Bangalore

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

Practice Midterm 1. Problem Points Score TOTAL 50

Points Missed on Page page 1 of 8

CSE 331 Final Exam 6/7/16 Sample Solution

Final Examination Semester 2 / Year 2011

ICOM 4015 Advanced Programming Laboratory. Chapter 1 Introduction to Eclipse, Java and JUnit

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

H212 Introduction to Software Systems Honors

Object-Oriented Programming and Software Engineering CITS1001 MID-SEMESTER TEST

Graphical User Interfaces. Comp 152

CSCI 135 Midterm Fundamentals of Computer Science I Fall 2011

Lab 5 Classy Chat. XMPP Client Implementation --- Part 2 Due Oct. 19 at 11PM

1st Semester Examinations CITS1001 3

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

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

CIS 110 Introduction to Computer Programming Summer 2014 Final. Name:

SPRING 13 CS 0007 FINAL EXAM V2 (Roberts) Your Name: A pt each. B pt each. C pt each. D or 2 pts each

Expressions and Data Types CSC 121 Spring 2015 Howard Rosenthal

Graphical User Interface (GUI)

CSE 331 Final Exam 6/10/14

Java. GUI building with the AWT

BASIC COMPUTATION. public static void main(string [] args) Fundamentals of Computer Science I

I have neither given nor received any assistance in the taking of this exam.

Computational Expression

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

CSCI 135 Exam #0 Fundamentals of Computer Science I Fall 2012

CIS220 In Class/Lab 1: Due Sunday night at midnight. Submit all files through Canvas (25 pts)

Examination Questions Midterm 1

CSE wi Final Exam 3/12/18 Sample Solution

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

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

Practice Midterm 1 Answer Key

Computer Science 62. Midterm Examination

Programming - 2. Common Errors

Java Simple Data Types

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

Tutorial 3: Unit tests and JUnit

COS 126 General Computer Science Fall Written Exam 1

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

Final Exam. COMP Summer I June 26, points

CS 455 Final Exam Fall 2013 [Bono] December 12, 2013

Array Basics: Outline. Creating and Accessing Arrays. Creating and Accessing Arrays. Arrays (Savitch, Chapter 7)

cis20.1 design and implementation of software applications I fall 2007 lecture # I.2 topics: introduction to java, part 1

COMP 401 Midterm. Tuesday, Oct 18, pm-3:15pm. Instructions

CMSC 433 Section 0101 Fall 2012 Midterm Exam #1

EXAMINATIONS 2010 END-OF-YEAR COMP 102 INTRODUCTION TO COMPUTER PROGRAM DESIGN

You will not be tested on JUnit or the Eclipse debugger. The exam does not cover interfaces.

CSE 331 Final Exam 3/16/15 Sample Solution

State Application Using MVC

AP CS Unit 7: Interfaces. Programs

What is an Iterator? An iterator is an abstract data type that allows us to iterate through the elements of a collection one by one

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

CSE 331 Midterm Exam 2/13/12

Client-side GUI. A simple Swing-gui for searching for proudcts

CS 231 Data Structures and Algorithms, Fall 2016

CSE 143. Linked Lists. Linked Lists. Manipulating Nodes (1) Creating Nodes. Manipulating Nodes (3) Manipulating Nodes (2) CSE 143 1

Command-Line Applications. GUI Libraries GUI-related classes are defined primarily in the java.awt and the javax.swing packages.

CS 61B Discussion Quiz 1. Questions

CS 101 Fall 2006 Midterm 1 Name: ID:

Programming Assignment 7 (100. Points)

Lecture 9. Lecture

MID-SEMESTER TEST 2014

CSCI 135 Exam #2 Fundamentals of Computer Science I Fall 2013

AP CS Unit 11: Graphics and Events

CSCI 135 Exam #2 Fundamentals of Computer Science I Fall 2013

Introduction to Graphical User Interfaces (GUIs) Lecture 10 CS2110 Fall 2008

CS2401 QUIZ 5 February 26, questions / 20 points / 20 minutes NAME:..

Object-oriented programming in Java (2)

Final Exam. CS2110 Spring May 12, Total. Max Score

CS18000: Problem Solving And Object-Oriented Programming

Selected Questions from by Nageshwara Rao

CS 201 Advanced Object-Oriented Programming Lab 5 - Sudoku, Part 1 Due: March 3/4, 11:30 PM

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

COMP 102: Test 2 Model Solutions

Expressions and Data Types CSC 121 Fall 2015 Howard Rosenthal

Input from Files. Buffered Reader

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

CSE 331 Midterm Exam Sample Solution 2/13/12

CSE 331 Final Exam 6/5/17. Name UW ID#

CIS 110 Fall 2016 Introduction to Computer Programming 13 Oct 2016 Midterm Exam Answer Key

COS 126 General Computer Science Spring Written Exam 1

Intro. Scheme Basics. scm> 5 5. scm>

Java Programming. What is a program? Programs Recipes. Programs as Recipes 8/16/12. Pancakes In one bowl. mix: 1½ cup flour

Transcription:

Fall, 2013 CIT 590 Programming Languages and Techniques Final - 2 hrs Make sure to write down any assumptions you make. Please feel free to use the back of the answer booklet to continue (or begin) solutions. Always put down a question number for it. Write your name and your email on this first page. There are 15 questions in total. 1

Questions. 1. You are given the following code that represents Complex numbers. class Complex{ Double realpart; Double imaginarypart; public Complex(Double realpart, Double imaginarypart){ this.realpart = realpart; this.complexpart = imaginarypart; public add(complex c){ this.realpart += c.realpart; this.imaginarypart += c.imaginarypart; Write the equals method for this class. ( 2 pts) 2

2. How does one pause the execution of a program for 5 seconds. Write a single line of code for this. (1 pt) 3. Sketch out what the UI will look like after the running of the following code. This does not need to look perfect, but the relative arrangements do matter. (3 pts) frame = new JFrame("frame this!"); frame.setlayout(new FlowLayout()); panel1 = new JPanel(); panel1.setlayout(new BorderLayout()); button1 = new JButton("first"); button2 = new JButton("second"); panel2 = new JPanel(); panel2.setlayout(new GridLayout(1,3)); button3 = new JButton("1"); button4 = new JButton("3"); button5 = new JButton("2"); panel1.add(button1, BorderLayout.NORTH); panel1.add(button2, BorderLayout.EAST); panel2.add(button3); panel2.add(button4); panel2.add(button5); frame.add(panel1); frame.add(panel2); frame.pack(); frame.setsize(1024,768); frame.setvisible(true); 3

4. If a class extends Observable, what are the two lines of code needed in order to inform the Observer that something has happened and it needs to run its update method? (1 pt) 5. Who was your best partner this semester? If you do not remember the name, please name the assignment (we do not need a number, just the description like Calculator will be fine). (1 pt) 6. Who was your worst partner this semester? Same instructions as above if you do not remember the name. Also, these are 2 free points, so do not leave this blank! (1 pt) 4

7. Find the bugs in the following programs. A bug is something that Eclipse will point out with a red squiggly or something that has unintentional consequences.please explain what the bug is (a word/short sentence is sufficient) and then write out the fix. Some of the fixes are a small change while some would require potentially writing more code.(7 pts) p u b l i c s t a t i c void main ( S t r i n g [ ] args ) { FileReader f i l e R e a d e r = new FileReader ( finalexam. txt ) ; i n t x = 4 5 ; i n t y = 5 ; i f ( x = 2) & ( y = 5){ System. out. p r i n t l n ( x i s two and y i s f i v e ) ; 5

p u b l i c c l a s s DoSomething implements Runnable { p u b l i c void s t a r t ( ) { f o r ( i n t i = 0 ; i < 1 0 ; i++) { System. out. p r i n t l n ( i am here ) ; p u b l i c s t a t i c void main ( S t r i n g [ ] args ) { ArrayList<String > mylist = new ArrayList<String >(); mylist. add ( ar ) ; mylist. add ( bh ) ; mylist. add ( us ) ; mylist. add ( nu ) ; mylist. add ( rm ) ; I t e r a t o r <String > i t = mylist. i t e r a t o r ( ) ; while ( i t. hasnext ( ) ) { S t r i n g value = i t. next ( ) ; i f ( value. e q u als ( bh ) ) mylist. remove ( value ) ; 6

8. 9. Why are abstract classes useful? Can everything that we do with interfaces be done by declaring abstract classes instead? Give us an example of an inbuilt abstract class in Java and an inbuilt interface in Java. (4 pts) 10. When saving a java project as an executable, what file format is this executable stored as? (1 pt) 11. What is the output of the following code? Show your working to get partial credit. (4 pts) p u b l i c s t a t i c void main ( S t r i n g [ ] args ) { i n t n1 = 2435; i n t n2 = 0 ; i n t temp = 0 ; while ( n1 > 0){ temp = ++n1%10; n2 = n2++ 10 + temp ; n1 = n1 /10; System. out. p r i n t l n ( n1 + n2 + Crazy number i s + n1 + n1 ) ; 7

12. True or False (10 pts) For a string variable s, the comparison (s == null) and (s == ) are effectively doing the same thing. Integer.parseInt( 5 ) is an example usage of a static method. int x = 5; and Integer x = 5; mean the same thing. Every class has to have a parameter less constructor. A class can implement multiple interfaces. Every class has to have a name. The regular expression [a-z]+[0-9]*?\\slanding will match the string apollo11 landing. When using MVC, the model should depend on the view. In pair programming it is best to code silently. A variable in a final class cannot be modified. 8

13. In each of the following, write a few Java statements to perform the required task. Do not write complete classes or complete methods. (10 pts) (a) Set a boolean variable x to be true if the string s begins with the letter y and to false otherwise. (b) Given a string whose length is even, extract the two characters (in the form of a string) that are in the middle. For a word like computer we want to extract pu. (c) A variable namephonemapping that is intended to provide information about people s phone nums is declared to be of type HashMap<String, Integer>. Using just one additional variable, loop through the mapping and print every phone number on a separate line. Print just the phone number. (d) Print true if a variable mybutton is an instance of the CalculatorButton class and print false otherwise. 9

(e) Check to see if an english word begins with an a, ends with a t and has the word man within it. (the word adamant would be a word that satisfies the condition). 14. Name 2 JUnit methods other than assertequals and specify what type of arguments each one expects. (2 pts) 15. Suppose we want to create a TimerTask that print out Hello World! every x seconds. We do this by defining a class called SayHello. Write out this class in its entireity. (3 pts) 10