Fall 2011 Final Test

Size: px
Start display at page:

Download "Fall 2011 Final Test"

Transcription

1 Fall 2011 Final Test Answer all questions You are allowed to bring in one unmarked textbook on Java and the lecture slides (unmarked). No other material will be allowed. This test has 11 pages. If you decide to show your changes to question 2 using this question paper itself, please write your name and student number below and make sure we staple this test to your exam booklet. Name : Student # : 1

2 Question 1) (Full Marks 20) Consider the following Java application. Indicate what will be the output generated by the application. public class Q4 { public static int process(string s){ StringTokenizer listtokens; listtokens = new StringTokenizer(s, "(/)"); int x1, x2; x1 = Integer.parseInt(listTokens.nextToken()); x2 = Integer.parseInt(listTokens.nextToken()); return x1/x2; public static double[] extract(string s){ StringTokenizer mytokens; String atoken; double result[]; int index = 0; mytokens = new StringTokenizer(s, "; "); System.out.println("We have " + mytokens.counttokens() + " tokens"); result = new double[mytokens.counttokens()]; while (mytokens.hasmoreelements()){ atoken = mytokens.nexttoken(); result[index] = process(atoken); index++; return result; public static void main(string a[]){ double result[]; String input = "(25/6); 3/6; 12/4"; result = extract(input); for (int i = 0; i < result.length; i++){ System.out.println("result[" + i + "]= " + result[i]); Answer : We have 3 tokens result[0]= 4.0 result[1]= 0.0 result[2]= 3.0 Question 2) (Full Marks = 30) Three applications are given below. Each application has one or more compile-time and/or run-time problem (or problems). The error message from the Eclipse system is 2

3 also given below. Select any two of the applications. For each application you selected, a) fix all errors, so that the application works as intended. b) explain what was the problem and how your changes solve the problem. (Hint: There may be other problems which will come up when the problem reported by Eclipse has been fixed.) Application i) This application involves the classes MyClass and MyExtendedClass given below. There are some compile-time errors as indicated by the comments. In fixing the errors, you are not allowed to delete any line or change any statement to a comment. You are only responsible for fixing the compile-time errors by adding one or more lines of code or code fragments. public class MyClass { String a = ""; void m1(int m, int n) { a = a + m; System.out.println("Inside m1 in MyClass " + n); void m2(char ch) { // Method m2 is defined twice with // same signature change one of // the signatures System.out.println("Inside m2 in MyClass " + ch); void m2(char ch) { // Method m2 is defined twice with // same signature change one of // the signatures System.out.println("Inside method m2 in MyClass " + ch); m2(ch); public class MyExtendedClass extends MyClass { String b = ""; void m1(int n) { b = b + n; m1(n, n); System.out.println("Inside m1 in MyExtendedClass " + n); void m2(char ch) { System.out.println("Inside m2 in MyExtendedClass " + ch); public static void main(string args[]){ MyClass obj2 = new MyExtendedClass(); obj2.m1(2); // There is no method with a // matching signature in MyClass // cast to MyExtendedClass obj2.b = "John";// MyClass does not have variable b. // cast to MyExtendedClass 3

4 One fix: public class MyClass { String a = ""; void m1(int m, int n) { a = a + m; System.out.println("Inside m1 in MyClass " + n); void m2(char ch) { System.out.println("Inside m2 in MyClass " + ch); void m2a(char ch) { System.out.println("Inside method3 in MyClass " + ch); m2(ch); public class MyExtendedClass extends MyClass { String b = ""; void m1(int n) { b = b + n; m1(n, n); System.out.println("Inside m1 in MyExtendedClass " + n); void m2(char ch) { System.out.println("Inside m2 in MyExtendedClass " + ch); public static void main(string args[]){ MyClass obj2 = new MyExtendedClass(); ((MyExtendedClass) obj2).m1(2); ((MyExtendedClass) obj2).b = "John"; Application ii) The following application extends class ListGeneral ( available in the additional document you received). The program has no compile-time error but aborted with a run-time error as noted below. Your task is to fix the problem. You must retain the recursive algorithm used below in your corrected version. For your convenience, the algorithm used is given below: 1) (Non-recursive case) if a list is empty, its length is 0. 2) (Recursive case) Otherwise the length of the list is 1 + the length of the list pointed at by variable next in the first element in the list. public class Q3b extends ListGeneral{ public int numelements(){// The method returns how many elements // we have in the linked list we created. restart(); if (endoflist()){ 4

5 return 0; else{ getnextnode(); return 1 + numelements(); public static void main(string a[]){ Q3b mylist = new Q3b(); mylist.addbeforecurrent("you"); mylist.addbeforecurrent("are"); mylist.addbeforecurrent("how"); System.out.println("Number of elements in mylist is " + mylist.numelements()); Problem encountered: The program aborted with the message: Exception in thread "main" java.lang.stackoverflowerror at Q3b.numElements(Q3b.java:10) Diagnosis- numelements is not making any progress since it starts by calling restart(). One fix : public class Q3b extends ListGeneral{ public int numelements(){ restart(); return countelements(); public int countelements(){ if (endoflist()){ return 0; else{ getnextnode(); return 1 + countelements(); public static void main(string a[]){ Q3b mylist = new Q3b(); mylist.addbeforecurrent("you"); mylist.addbeforecurrent("are"); mylist.addbeforecurrent("how"); System.out.println("Number of elelments in mylist is " + mylist.numelements()); Application iii) The following application converts each object of class String in array mystrings into an integer value and saves the integer value in the array myints. I anticipated two problems: a) the array myints may not be large enough, resulting in an ArrayIndexOutOfBounds Exception. 5

6 b) Some strings in mystrings may have illegal characters, resulting in an exception of the NumberFormatException class. Just to make sure, I threw in another catch block to catch all remaining exceptions and came up with the following code: public class Q3c { public static void main(string a[]){ String mystrings[] = {"312", "341", "3a2", "72"; int myints[] = new int[5]; for (int i = 0; i < mystrings.length; i++){ try{ myints[i] = Integer.parseInt(myStrings[i]); catch(exception e){ System.out.println("Some exception happened"); catch(numberformatexception nfe){//a compilation error here System.out.println("NumberFormatException occured " + "when processing " + mystrings[i]); catch(arrayindexoutofboundsexception abe)//a compilation error // here System.out.println("ArrayIndexOutOfBoundsException " + "occured for i = " + i); Diagnosis: The first catch block catches all exceptions. This is why the other catch blocks are unreachable. One fix : Put the first catch block in the last position. Question 3) This question has two alternatives. Alternative i carries 30 marks, while alternative ii carries 20 marks, so that you automatically lose 10 marks if you answer alternative II. Do not answer alternative ii if you can answer alternative i. Alternative I) (Full Marks 30) This question uses class ListGeneral which was discussed in class. Class ListGeneral is defined in the additional document you have received. Your problem is to define a class called Question3 which includes the following: a) A private variable called mylist of type ListGeneral, 6

7 b) A public method insert(string x) which inserts x at the end of the linked list pointed at by mylist. The method insert must call a recursive method in achieving its objective. c) A public method called reverselist() which returns an object of class ListGeneral corresponding to the reverse of mylist. See example below for an explanation of what is meant by reverse of a list. The method reverselist must call a recursive method in achieving its objective. d) A public method deleteremainingelements(int index) that deletes all elements in mylist, after the element in position index. Here the first element(i.e., the element pointed at by firstnode) has index 0, the element pointed at by the first element has index 1 and so on. You are free to other methods/variables and constructors as needed. Note that I did not ask you to write a tostring() method. Example: Consider the Java application below: public class Test{ public static void main(string a[]){ Question3 alist; alist = new Question3(); alist.insert("year"); alist.insert("new"); alist.insert("happy"); alist.insert("a"); alist.insert("you"); alist.insert("wish"); // Line 10 System.out.println("aList: \n" + alist); System.out.println("aList reversed: \n" + alist.reverselist()); alist.deleteremainingelements(2); // Line 14 System.out.println("aList after deleting all elements " + "after element 2: \n" + alist); After executing line 10, we expect the following linked list that alist is pointing at: Here we assign an index value to each node from the first to the last so that the nodes containing year, new, happy, a, you and wish 7

8 have indices 0, 1, 2, 3, 4 and 5 respectively. If blist is the reverse of alist, then blist is also a list having six nodes, with the same strings year, new, happy, a, you and wish shown above, but the nodes containing these strings have indices 5, 4, 3, 2, 1, and 0 respectively, so that blist, the reverse of alist, is as shown below: After line 14 is executed, we expect all elements in alist after the element having index 2 to be deleted, so that we expect that alist will be as follows: The output produced by the application is given below. alist: year new happy a you wish alist reversed: wish you a happy new year alist after deleting all elements after element 2: year new happy One possible solution: public class Final11Q1 { ListGeneral mylist; public Final11Q1(){ mylist = new ListGeneral(); 8

9 private void insertatendoflist(string x){ if (mylist.endoflist()){// If the end of the list is encountered, // insert x mylist.addbeforecurrent(x); else { mylist.getnextnode(); // Otherwise, go to the next node // and call the method recursively insertatendoflist(x); public void insert(string x){ // Method inserts starts the search from // the beginning of the list mylist.restart(); // and calls a recursive method // insertatendoflist. insertatendoflist(x); /* * In deleteremainingelements(int index) we have assumed that if the * value of index is refers to a node beyond the last node in the * linked list, nothing happens. Other students may assume that the * value of index is such that this cannot happen. */ public void deleteremainingelements(int index){ // Method deleteremainingelements mylist.restart(); // starts search from the first node while ((index >= 0) && (!mylist.endoflist())){// as long as the mylist.getnextnode();//end of the list is not encountered // and we have not found the node we index --; // are looking for, keep going forward. while (!mylist.endoflist()){// Once we find the first node we are mylist.removecurrent();//looking for, delete it and keep // deleting subsequent nodes until // end of the list is encountered. public ListGeneral reverselist(){ // ReverseList starts by creating an empty list ListGeneral listreversed; // When the process ends, this list will be the reverse of the list. listreversed = new ListGeneral(); mylist.restart(); // start at the beginning return reverselist(listreversed);// This is the recursive method which actually // creates the reversed list. public String tostring(){ 9

10 return mylist.tostring(); private ListGeneral reverselist(listgeneral alist){ Object valueincurrentnode; if (mylist.endoflist()) { // If the end of list is encountered the argument alist // gives the reversed list. return alist; else {// Otherwise, take the value in the current node in mylist // add the value at the beginning valueincurrentnode = mylist.currentvalue(); alist.restart();// of the list alist alist.addbeforecurrent(valueincurrentnode); mylist.getnextnode();// go to the next node in mylist return reverselist(alist);// Call method recursively public static void main(string a[]){ Final11Q1 alist; alist = new Final11Q1(); alist.insert("year"); alist.insert("new"); alist.insert("happy"); alist.insert("a"); alist.insert("you"); alist.insert("wish"); System.out.println("aList: \n" + alist); System.out.println("aList reversed: \n" + alist.reverselist()); alist.deleteremainingelements(2); System.out.println("aList after deleting all elements after element 2: \n" + alist); Alternative II) (Full Marks 20) Consider the Java application given below. It uses ListGeneral defined in the additional document you received. Draw a diagram indicating the data structure you have after the application has executed the last call to addbeforecurrent. Your data structure must show all the objects of class Node and their contents, the values of firstnode, currentnode and previousnode. public class Q1b { public static void main(string a[]){ ListGeneral mylist; mylist = new ListGeneral(); mylist.addbeforecurrent("john"); mylist.addbeforecurrent("tom"); mylist.addaftercurrent("mary"); mylist.restart(); mylist.getnextnode(); mylist.getnextnode(); mylist.removecurrent(); mylist.addbeforecurrent(new Integer(5)); mylist.addbeforecurrent(new Integer(7)); 10

11 System.out.println(myList); Question 4) Answer any one of alternatives I and II given below. (Full Marks 20) Alternative I) Our objective is to develop an information system that allows us to i) store a number of (key, value) pairs, and ii) retrieve information from such a system by specifying the contents of key. You may assume that a given key value appears at most once in the information system. Two examples of such pairs are given below: a) In a student information system, value could be an object of a Student class and the key could be the student number. In this case, you may retrieve an object of class Student by specifying his/her student number as a key value. b) In a bank, value could be an object of a Customer class (for instance containing the name, address and the account balance of the customer) and the key could be the account number. In this case, if you supply an account number as a key value, you may retrieve an object of class Customer corresponding to that account number. Your problem is to develop a Java class called MyInformationSystem with type parameter T which includes the following : a) A private inner class called Pair, with type parameter T, that has the following instance variable value of type T, instance variable key of type String, method keymatches(string keyvalue) which returns true if the supplied keyvalue matches the value of key in the current object, constructor method as needed. b) A private instance variable called mylist of type ArrayList with appropriate type parameter, to store the objects of class Pair<T>. c) Constructor as needed. d) A public method insert(t value, String key) which uses the supplied key and value to create a new object of class Pair, inserts the new object into mylist. (You are free to decide the position in mylist where you wish to insert the new object you created). e) A public method retrieve(string keyvalue) which searches all elements in mylist for an object of class Pair with a key that matches keyvalue. If the search succeeds in locating such an object, it returns the instance variable value in the 11

12 object. If the search fails for any reason, the method should throw an exception of class Exception. A Java main method is given below illustrating the features described above. public static void main(string a[]){ String result; String keylist[] = {"126", "536", "428", "245"; MyInformationSystem<String> namestudentnumberlist; namestudentnumberlist = new MyInformationSystem<String>(); namestudentnumberlist.insert("john", "245");// John has // student number 245 namestudentnumberlist.insert("tom", "126"); namestudentnumberlist.insert("mary", "536"); namestudentnumberlist.insert("mark", "821"); for (int i = 0; i < keylist.length; i++){ try{ result = namestudentnumberlist.retrieve(keylist[i]); System.out.println("For key " + keylist[i] + " the matching value is " + result); catch(exception e){ System.out.println("No Match with " + keylist[i]); The output produced is as follows: For key 126 the matching value is Tom For key 536 the matching value is Mary No Match with 428 For key 245 the matching value is John\ One solution : public class MyInformationSystem<T> { /* * Class Pair is an inner class that simply encapsulates the key and the * value */ private class Pair<T>{ // The type parameter T refers to the type of T value; String key; Pair(T value, String key){ this.value = value; this.key = key; // object that value is pointing at // Constructor just initializes the // instance variables. boolean keymatches(string keyvalue){ // Method keymatches returns return keyvalue.equals(key); // true if the current object // satisfies the condition for retrieval. 12

13 private ArrayList<Pair<T>> mylist; // As stated in the question public MyInformationSystem(){ //Constructor just initializes the ArrayList mylist = new ArrayList<Pair<T>>(); public void insert(t value, String key){ for insert //insert adds the new(key, mylist.add(0, new Pair(value, key));// value) pair as the // first element in mylist public T retrieve(string keyvalue) throws Exception{// 5 marks // retrieve returns Pair<T> keyvaluepair; // the object with a matching key. // If none found, it throws an exception. for (int i = 0; i < mylist.size(); i++){ // Look through all keyvaluepair = mylist.get(i); // elements in mylist //if the ith element has a matching key if ((keyvaluepair.key).equals(keyvalue)){// return the return keyvaluepair.value; // value throw (new Exception("match not found")); // If search fails, // throw an exception Alternative II) You have to develop a Java application involving mouse events and mouse motion events. Details of the application are given below: a) Your application initially displays a square of size 20 X 20 pixels at some convenient location within the frame as shown below. The perimeter of the square should be shown in black. 13

14 Hints: i) use Color.BLACK, ii) drawrect(x0, y0, width, height) displays a rectangle with the bounding box of the rectangle having its top left corner at (x0, y0) and with its dimensions as specified. c) The user can select either the top edge or the left edge of the square by pressing the left mouse button with the cursor very close to the edge (for instance within 5 pixels of the edge) he/she wishes to select. When the user selects an edge, the perimeter of the square should be shown in green (Hint: use Color.GREEN). d) If the user now drags the mouse, the selected edge should move with the mouse, so that the square will become smaller or bigger, depending on whether the user is moving the mouse towards the opposite edge or away from the opposite edge. Remember that a square has the same width and height, so that if the user changes the width, the height should change automatically and if the user is changing the height, the width should change automatically. As long as the left mouse button is pressed, the perimeter of the square should be shown in green. An example of dragging the top edge away from the bottom edge is shown below: 14

15 e) If the user releases the left mouse button, the rectangle will remain at the same position it occupied the last time it was displayed. The only difference is that the perimeter of the square should be shown in black. Hints: For your convenience, the java application for the Tictactoe problem, discussed in class, is given in the appendix that you have received. One solution: public class ChangeSquare extends JFrame{ int referencepointx, referencepointy; // gives the coordinates of the top // left corner of bounding box int lastmousepositionx, lastmousepositiony;// coordinates of last mouse position int heightorwidth; Color squarecolor; int whichedgeisselected;//user can select either the left edge or the top edge. // if left edge is selected whichedgeisselected = 1 // otherwise it is 2. boolean perimeterselected = false;// true if the user presses mouse button on // the left edge or the top edge of the square public ChangeSquare(){ super("showing square"); referencepointx = 100; // initial coordinate of bounding box referencepointy = 100; heightorwidth = 20; squarecolor = Color.BLACK; addmouselistener( new MouseAdapter(){ public void mousepressed(mouseevent e ){ // if mouse is pressed lastmousepositionx = e.getx(); // get the coordinates //where the lastmousepositiony = e.gety(); // mouse was pressed, perimeterselected = false; if (onperimeter(lastmousepositionx, lastmousepositiony)){ // If the user presses mouse button on the top edge or the // left edge of the square perimeterselected is true and // the color becomes green perimeterselected = true; squarecolor = Color.GREEN; repaint(); public void mousereleased(mouseevent e ){ // when the left mouse button is released 15

16 ); // the color becomes black again and the flag is reset. // perimeterselected is false squarecolor = Color.BLACK; perimeterselected = false; repaint(); addmousemotionlistener( new MouseMotionAdapter(){ public void mousedragged( MouseEvent e ){ int xvalue, yvalue; int newmousepositionx, newmousepositiony; if (perimeterselected){ // There is a reaction to mouse dragging only if the // user has selected the perimeter by pressing left // mouse button ); setsize(300,300); setvisible(true); newmousepositionx = e.getx(); newmousepositiony = e.gety(); updatesquare(newmousepositionx, newmousepositiony); // update the size of the square and the // coordinates of the left corner of the // bounding box. repaint(); /* * updatesquare is called when the perimeter is selected and the user has dragged * the mouse. The method determines how the top left corner of the bounding box * the dimension of the square and the position of the last mouse movement * have to be updated. The arguments are the current coordinates of the mouse. */ private void updatesquare(int newmousepositionx, int newmousepositiony){ int changeinx, changeiny; if (whichedgeisselected == 1){ // If left edge is selected only the x-coordinate of the top left // corner will change. The amount of change in the x-coordinate // as well as the dimension of the square is the amount of the // mouse displacement. Note that referencepointx is increased // while the dimension is decreased by the amount of change. changeinx = newmousepositionx - lastmousepositionx; referencepointx += changeinx; heightorwidth -= changeinx; 16

17 lastmousepositionx = newmousepositionx; else { // Same as above except that we consider the change in y- // coordinate. changeiny = newmousepositiony - lastmousepositiony; referencepointy += changeiny;// heightorwidth -= changeiny; lastmousepositiony = newmousepositiony; /* * onperimeter returns true if the user has selected the top edge or the * left edge. Otherwise it returns false. * An edge is selected if the user presses the left mouse button with the * cursor within 5 pixels of an edge. */ private boolean onperimeter(int mousepositionx, int mousepositiony){ if ((Math.abs(mousePositionX - referencepointx)< 5) && (mousepositiony >= referencepointy) && (mousepositiony <= referencepointy + heightorwidth)){ // The user has selected the left edge if the mouse is within // 5 pixels of the x-value of the top left corner of bounding box // and y-value of mouse is within the top and the bottom edge whichedgeisselected = 1; return true; else if ((Math.abs(mousePositionY - referencepointy)< 5) && (mousepositionx >= referencepointx) && (mousepositionx <= referencepointx + heightorwidth)){ // Same as above for the top edge whichedgeisselected = 2; return true; else return false; public void paint(graphics g){ super.paint(g); g.setcolor(squarecolor); g.drawrect(referencepointx, referencepointy, heightorwidth, heightorwidth); public static void main(string args[]){ ChangeSquare myframe; myframe = new ChangeSquare(); 17

Introduction to Linked Data Structures

Introduction to Linked Data Structures Introduction to Linked Data Structures A linked data structure consists of capsules of data known as nodes that are connected via links Links can be viewed as arrows and thought of as one way passages

More information

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

Midterm Test II Object Oriented Programming in Java Computer Science, University of Windsor Fall 2014 Time 2 hours. Answer all questions Midterm Test II 60-212 Object Oriented Programming in Java Computer Science, University of Windsor Fall 2014 Time 2 hours Answer all questions Name : Student Id # : Only an unmarked copy of a textbook

More information

Practice Midterm 1 Answer Key

Practice Midterm 1 Answer Key CS 120 Software Design I Fall 2018 Practice Midterm 1 Answer Key University of Wisconsin - La Crosse Due Date: October 5 NAME: Do not turn the page until instructed to do so. This booklet contains 10 pages

More information

Practice Midterm 1. Problem Points Score TOTAL 50

Practice Midterm 1. Problem Points Score TOTAL 50 CS 120 Software Design I Spring 2019 Practice Midterm 1 University of Wisconsin - La Crosse February 25 NAME: Do not turn the page until instructed to do so. This booklet contains 10 pages including the

More information

Chapter 4 Defining Classes I

Chapter 4 Defining Classes I Chapter 4 Defining Classes I This chapter introduces the idea that students can create their own classes and therefore their own objects. Introduced is the idea of methods and instance variables as the

More information

Lecture 3: Java Graphics & Events

Lecture 3: Java Graphics & Events Lecture 3: Java Graphics & Events CS 62 Fall 2017 Kim Bruce & Alexandra Papoutsaki Text Input Scanner class Constructor: myscanner = new Scanner(System.in); can use file instead of System.in new Scanner(new

More information

Programming - 2. Common Errors

Programming - 2. Common Errors Common Errors There are certain common errors and exceptions which beginners come across and find them very annoying. Here we will discuss these and give a little explanation of what s going wrong and

More information

AP CS Unit 12: Drawing and Mouse Events

AP CS Unit 12: Drawing and Mouse Events AP CS Unit 12: Drawing and Mouse Events A JPanel object can be used as a container for other objects. It can also be used as an object that we can draw on. The first example demonstrates how to do that.

More information

Lecture 5: Java Graphics

Lecture 5: Java Graphics Lecture 5: Java Graphics CS 62 Spring 2019 William Devanny & Alexandra Papoutsaki 1 New Unit Overview Graphical User Interfaces (GUI) Components, e.g., JButton, JTextField, JSlider, JChooser, Containers,

More information

CSE 11 Midterm Fall 2008

CSE 11 Midterm Fall 2008 Signature cs11f Name Student ID CSE 11 Midterm Fall 2008 Page 1 (10 points) Page 2 (22 points) Page 3 (23 points) Page 4 (17 points) Page 5 (12 points) Total (84 points = 80 base points + 4 points EC [5%])

More information

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

1. Which of the following is the correct expression of character 4? a. 4 b. 4 c. '\0004' d. '4' Practice questions: 1. Which of the following is the correct expression of character 4? a. 4 b. "4" c. '\0004' d. '4' 2. Will System.out.println((char)4) display 4? a. Yes b. No 3. The expression "Java

More information

COE318 Lecture Notes Week 10 (Nov 7, 2011)

COE318 Lecture Notes Week 10 (Nov 7, 2011) COE318 Software Systems Lecture Notes: Week 10 1 of 5 COE318 Lecture Notes Week 10 (Nov 7, 2011) Topics More about exceptions References Head First Java: Chapter 11 (Risky Behavior) The Java Tutorial:

More information

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

Block I Unit 2. Basic Constructs in Java. AOU Beirut Computer Science M301 Block I, unit 2 1 Block I Unit 2 Basic Constructs in Java M301 Block I, unit 2 1 Developing a Simple Java Program Objectives: Create a simple object using a constructor. Create and display a window frame. Paint a message

More information

EXAM Computer Science 1 Part 1

EXAM Computer Science 1 Part 1 Maastricht University Faculty of Humanities and Science Department of Knowledge Engineering EXAM Computer Science 1 Part 1 Block 1.1: Computer Science 1 Code: KEN1120 Examiner: Kurt Driessens Date: Januari

More information

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

Ryerson University Department of Electrical & Computer Engineering COE618 Midterm Examination February 26, 2013 Ryerson University Department of Electrical & Computer Engineering COE618 Midterm Examination February 26, 2013 Name: Student # : Time: 90 minutes Instructions This exam contains 6 questions. Please check

More information

H212 Introduction to Software Systems Honors

H212 Introduction to Software Systems Honors Introduction to Software Systems Honors Lecture #19: November 4, 2015 1/14 Third Exam The third, Checkpoint Exam, will be on: Wednesday, November 11, 2:30 to 3:45 pm You will have 3 questions, out of 9,

More information

CSIS 10A Assignment 14 SOLUTIONS

CSIS 10A Assignment 14 SOLUTIONS CSIS 10A Assignment 14 SOLUTIONS Read: Chapter 14 Choose and complete any 10 points from the problems below, which are all included in the download file on the website. Use BlueJ to complete the assignment,

More information

CS 231 Data Structures and Algorithms Fall Binary Search Trees Lecture 23 October 29, Prof. Zadia Codabux

CS 231 Data Structures and Algorithms Fall Binary Search Trees Lecture 23 October 29, Prof. Zadia Codabux CS 231 Data Structures and Algorithms Fall 2018 Binary Search Trees Lecture 23 October 29, 2018 Prof. Zadia Codabux 1 Agenda Ternary Operator Binary Search Tree Node based implementation Complexity 2 Administrative

More information

CSC 1351 The Twelve Hour Exam From Hell

CSC 1351 The Twelve Hour Exam From Hell CSC 1351 The Twelve Hour Exam From Hell Name: 1 Arrays (Ch. 6) 1.1 public class L { int [] data ; void append ( int n) { int [] newdata = new int [ data. length +1]; for ( int i =0;i< data. length ;i ++)

More information

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

CS-140 Fall 2018 Test 2 Version A Nov. 12, Name: CS-140 Fall 2018 Test 2 Version A Nov. 12, 2018 Name: 1. (10 points) For the following, Check T if the statement is true, or F if the statement is false. (a) X T F : A class in Java contains fields, and

More information

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

2. (True/False) All methods in an interface must be declared public. Object and Classes 1. Create a class Rectangle that represents a rectangular region of the plane. A rectangle should be described using four integers: two represent the coordinates of the upper left corner

More information

Advanced Java Unit 6: Review of Graphics and Events

Advanced Java Unit 6: Review of Graphics and Events Advanced Java Unit 6: Review of Graphics and Events This is a review of the basics of writing a java program that has a graphical interface. To keep things simple, all of the graphics programs will follow

More information

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

McGill University School of Computer Science COMP-202A Introduction to Computing 1 McGill University School of Computer Science COMP-202A Introduction to Computing 1 Midterm Exam Thursday, October 26, 2006, 18:00-20:00 (6:00 8:00 PM) Instructors: Mathieu Petitpas, Shah Asaduzzaman, Sherif

More information

CS 101 Fall 2005 Midterm 2 Name: ID:

CS 101 Fall 2005 Midterm 2 Name:  ID: This exam is open text book but closed-notes, closed-calculator, closed-neighbor, etc. Questions are worth different amounts (in particular, the final two questions are worth substantially more than any

More information

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. QUEEN'S UNIVERSITY SCHOOL OF COMPUTING HAND IN Answers Are Recorded on Question Paper CISC124, FALL TERM, 2013 FINAL EXAMINATION 7pm to 10pm, 18 DECEMBER 2013 Instructor: Alan McLeod If the instructor

More information

Graphical User Interfaces 2

Graphical User Interfaces 2 Graphical User Interfaces 2 CSCI 136: Fundamentals CSCI 136: Fundamentals of Computer of Science Computer II Science Keith II Vertanen Keith Vertanen Copyright 2011 Extending JFrame Dialog boxes Overview

More information

CS 201 Advanced Object-Oriented Programming Lab 10 - Recursion Due: April 21/22, 11:30 PM

CS 201 Advanced Object-Oriented Programming Lab 10 - Recursion Due: April 21/22, 11:30 PM CS 201 Advanced Object-Oriented Programming Lab 10 - Recursion Due: April 21/22, 11:30 PM Introduction to the Assignment In this assignment, you will get practice with recursion. There are three parts

More information

RAIK 183H Examination 2 Solution. November 10, 2014

RAIK 183H Examination 2 Solution. November 10, 2014 RAIK 183H Examination 2 Solution November 10, 2014 Name: NUID: This examination consists of 5 questions and you have 110 minutes to complete the test. Show all steps (including any computations/explanations)

More information

Phase 2: Due 11/28/18: Additional code to add, move and remove vertices in response to user mouse clicks on the screen.

Phase 2: Due 11/28/18: Additional code to add, move and remove vertices in response to user mouse clicks on the screen. Fall 2018 CS313 Project Implementation of a GUI to work with Graphs. Reminder: This is a pass/fail assignment. If you fail the assignment you will lose half a grade from your course grade. If you pass

More information

Chapter 1 GUI Applications

Chapter 1 GUI Applications Chapter 1 GUI Applications 1. GUI Applications So far we've seen GUI programs only in the context of Applets. But we can have GUI applications too. A GUI application will not have any of the security limitations

More information

2IS45 Programming

2IS45 Programming Course Website Assignment Goals 2IS45 Programming http://www.win.tue.nl/~wsinswan/programmeren_2is45/ Rectangles Learn to use existing Abstract Data Types based on their contract (class Rectangle in Rectangle.

More information

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

CSCI 135 Exam #0 Fundamentals of Computer Science I Fall 2012 CSCI 135 Exam #0 Fundamentals of Computer Science I Fall 2012 Name: This exam consists of 7 problems on the following 6 pages. You may use your single- side hand- written 8 ½ x 11 note sheet during the

More information

Dartmouth College Computer Science 10, Fall 2015 Midterm Exam

Dartmouth College Computer Science 10, Fall 2015 Midterm Exam Dartmouth College Computer Science 10, Fall 2015 Midterm Exam 6.00-9.00pm, Monday, October 19, 2015 105 Dartmouth Hall Professor Prasad Jayanti Print your name: Print your section leader name: If you need

More information

Practice exam for CMSC131-04, Fall 2017

Practice exam for CMSC131-04, Fall 2017 Practice exam for CMSC131-04, Fall 2017 Q1 makepalindrome - Relevant topics: arrays, loops Write a method makepalidrome that takes an int array, return a new int array that contains the values from the

More information

Final Exam CS 152, Computer Programming Fundamentals May 9, 2014

Final Exam CS 152, Computer Programming Fundamentals May 9, 2014 Final Exam CS 152, Computer Programming Fundamentals May 9, 2014 Name: NetID: Answer all questions in the space provided. Write clearly and legibly, you will not get credit for illegible or incomprehensible

More information

Arrays. COMS W1007 Introduction to Computer Science. Christopher Conway 10 June 2003

Arrays. COMS W1007 Introduction to Computer Science. Christopher Conway 10 June 2003 Arrays COMS W1007 Introduction to Computer Science Christopher Conway 10 June 2003 Arrays An array is a list of values. In Java, the components of an array can be of any type, basic or object. An array

More information

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

Queen s University Faculty of Arts and Science School of Computing CISC 124 Final Examination December 2004 Instructor: M. Lamb Queen s University Faculty of Arts and Science School of Computing CISC 124 Final Examination December 2004 Instructor: M. Lamb HAND IN Answers recorded on Examination paper This examination is THREE HOURS

More information

CS 132 Midterm Exam Fall 2004

CS 132 Midterm Exam Fall 2004 Date:1-Nov-2004 Time:7:00-9:00p.m. Permitted Aids:None CS 132 Midterm Exam Fall 2004 Please complete this page in ink. Last Name: Signature: First Name: ID: Please check off your Practicum Section: Dana

More information

CS 110 Practice Final Exam originally from Winter, Instructions: closed books, closed notes, open minds, 3 hour time limit.

CS 110 Practice Final Exam originally from Winter, Instructions: closed books, closed notes, open minds, 3 hour time limit. Name CS 110 Practice Final Exam originally from Winter, 2003 Instructions: closed books, closed notes, open minds, 3 hour time limit. There are 4 sections for a total of 49 points. Part I: Basic Concepts,

More information

Examination Questions Midterm 1

Examination Questions Midterm 1 CS1102s Data Structures and Algorithms 10/2/2010 Examination Questions Midterm 1 This examination question booklet has 9 pages, including this cover page, and contains 15 questions. You have 40 minutes

More information

AP CS Unit 11: Graphics and Events

AP CS Unit 11: Graphics and Events AP CS Unit 11: Graphics and Events This packet shows how to create programs with a graphical interface in a way that is consistent with the approach used in the Elevens program. Copy the following two

More information

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

I pledge by honor that I will not discuss this exam with anyone until my instructor reviews the exam in the class. Name: Covers Chapters 1-3 50 mins CSCI 1301 Introduction to Programming Armstrong Atlantic State University Instructor: Dr. Y. Daniel Liang I pledge by honor that I will not discuss this exam with anyone

More information

1.00/ Introduction to Computers and Engineering Problem Solving. Final / December 13, 2004

1.00/ Introduction to Computers and Engineering Problem Solving. Final / December 13, 2004 1.00/1.001 Introduction to Computers and Engineering Problem Solving Final / December 13, 2004 Name: Email Address: TA: Section: You have 180 minutes to complete this exam. For coding questions, you do

More information

Final Examination Semester 2 / Year 2010

Final Examination Semester 2 / Year 2010 Southern College Kolej Selatan 南方学院 Final Examination Semester 2 / Year 2010 COURSE : JAVA PROGRAMMING COURSE CODE : PROG1114 TIME : 2 1/2 HOURS DEPARTMENT : COMPUTER SCIENCE LECTURER : LIM PEI GEOK Student

More information

CSC System Development with Java. Exception Handling. Department of Statistics and Computer Science. Budditha Hettige

CSC System Development with Java. Exception Handling. Department of Statistics and Computer Science. Budditha Hettige CSC 308 2.0 System Development with Java Exception Handling Department of Statistics and Computer Science 1 2 Errors Errors can be categorized as several ways; Syntax Errors Logical Errors Runtime Errors

More information

Computer Programming, I. Laboratory Manual. Final Exam Solution

Computer Programming, I. Laboratory Manual. Final Exam Solution Think Twice Code Once The Islamic University of Gaza Engineering Faculty Department of Computer Engineering Fall 2017 ECOM 2005 Khaleel I. Shaheen Computer Programming, I Laboratory Manual Final Exam Solution

More information

Final Examination Semester 2 / Year 2011

Final Examination Semester 2 / Year 2011 Southern College Kolej Selatan 南方学院 Final Examination Semester 2 / Year 2011 COURSE COURSE CODE TIME DEPARTMENT LECTURER : JAVA PROGRAMMING : PROG1114 : 2 1/2 HOURS : COMPUTER SCIENCE : LIM PEI GEOK Student

More information

CSC Java Programming, Fall Java Data Types and Control Constructs

CSC Java Programming, Fall Java Data Types and Control Constructs CSC 243 - Java Programming, Fall 2016 Java Data Types and Control Constructs Java Types In general, a type is collection of possible values Main categories of Java types: Primitive/built-in Object/Reference

More information

Programmierpraktikum

Programmierpraktikum Programmierpraktikum Claudius Gros, SS2012 Institut für theoretische Physik Goethe-University Frankfurt a.m. 1 of 18 17/01/13 11:46 Java Applets 2 of 18 17/01/13 11:46 Java applets embedding Java applications

More information

CIS 265/506 Exam1 Spring 2012 Prof. V. Matos Exam Last Name First Name:

CIS 265/506 Exam1 Spring 2012 Prof. V. Matos Exam Last Name First Name: CIS 265/506 Exam1 Spring 2012 Prof. V. Matos Exam Last Name First Name: MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question. 1) Suppose x = 1, y = -1,

More information

Lecture 3. COMP1006/1406 (the Java course) Summer M. Jason Hinek Carleton University

Lecture 3. COMP1006/1406 (the Java course) Summer M. Jason Hinek Carleton University Lecture 3 COMP1006/1406 (the Java course) Summer 2014 M. Jason Hinek Carleton University today s agenda assignments 1 (graded) & 2 3 (available now) & 4 (tomorrow) a quick look back primitive data types

More information

CS 106A Midterm Review. Rishi Bedi, adapted from slides by Kate Rydberg and Nick Troccoli Summer 2017

CS 106A Midterm Review. Rishi Bedi, adapted from slides by Kate Rydberg and Nick Troccoli Summer 2017 + CS 106A Midterm Review Rishi Bedi, adapted from slides by Kate Rydberg and Nick Troccoli Summer 2017 Details n Only the textbook is allowed n n n The Art and Science of Java Karel Course Reader You will

More information

RAIK 183H Examination 2 Solution. November 11, 2013

RAIK 183H Examination 2 Solution. November 11, 2013 RAIK 183H Examination 2 Solution November 11, 2013 Name: NUID: This examination consists of 5 questions and you have 110 minutes to complete the test. Show all steps (including any computations/explanations)

More information

CSE 142 Sp02 Final Exam Version A Page 1 of 14

CSE 142 Sp02 Final Exam Version A Page 1 of 14 CSE 142 Sp02 Final Exam Version A Page 1 of 14 Basic reference information about collection classes that you may find useful when answering some of the questions. Methods common to all collection classes

More information

Review Chapter 6 in Bravaco. Short Answers 1. This type of method does not return a value. a. null b. void c. empty d. anonymous

Review Chapter 6 in Bravaco. Short Answers 1. This type of method does not return a value. a. null b. void c. empty d. anonymous Assignment 3 Methods Review CSC 123 Fall 2018 Notes: All homework must be submitted via e-mail. All parts of assignment must be submitted in a single e-mail with multiple attachments when required. Notes:

More information

CS/ENGRD 2110 SPRING 2018

CS/ENGRD 2110 SPRING 2018 CS/ENGRD 2110 SPRING 2018 Lecture 7: Interfaces and http://courses.cs.cornell.edu/cs2110 1 2 St Valentine s Day! It's Valentines Day, and so fine! Good wishes to you I consign.* But since you're my students,

More information

CIS 110 Introduction To Computer Programming. February 29, 2012 Midterm

CIS 110 Introduction To Computer Programming. February 29, 2012 Midterm CIS 110 Introduction To Computer Programming February 29, 2012 Midterm Name: Recitation # (e.g. 201): Pennkey (e.g. bjbrown): My signature below certifies that I have complied with the University of Pennsylvania

More information

CMSC 433 Section 0101 Fall 2012 Midterm Exam #1

CMSC 433 Section 0101 Fall 2012 Midterm Exam #1 Name: CMSC 433 Section 0101 Fall 2012 Midterm Exam #1 Directions: Test is closed book, closed notes. Answer every question; write solutions in spaces provided. Use backs of pages for scratch work. Good

More information

CS 113 PRACTICE FINAL

CS 113 PRACTICE FINAL CS 113 PRACTICE FINAL There are 13 questions on this test. The value of each question is: 1-10 multiple choice (4 pt) 11-13 coding problems (20 pt) You may get partial credit for questions 11-13. If you

More information

public void mouseexited (MouseEvent e) setminute(getminute()+increment); 11.2 public void mouseclicked (MouseEvent e) int x = e.getx(), y = e.gety();

public void mouseexited (MouseEvent e) setminute(getminute()+increment); 11.2 public void mouseclicked (MouseEvent e) int x = e.getx(), y = e.gety(); 11 The Jav aawt Part I: Mouse Events 11.1 public void mouseentered (MouseEvent e) setminute(getminute()+increment); 53 public void mouseexited (MouseEvent e) setminute(getminute()+increment); 11.2 public

More information

CmpSci 187: Programming with Data Structures Spring 2015

CmpSci 187: Programming with Data Structures Spring 2015 CmpSci 187: Programming with Data Structures Spring 2015 Lecture #13, Concurrency, Interference, and Synchronization John Ridgway March 12, 2015 Concurrency and Threads Computers are capable of doing more

More information

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

1.00/1.001 Introduction to Computers and Engineering Problem Solving Spring Quiz 2 1.00/1.001 Introduction to Computers and Engineering Problem Solving Spring 2010 - Quiz 2 Name: MIT Email: TA: Section: You have 80 minutes to complete this exam. For coding questions, you do not need

More information

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

First Name: AITI 2004: Exam 2 July 19, 2004 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

More information

Introduction to Computer Science II (ITI 1121) Midterm Examination

Introduction to Computer Science II (ITI 1121) Midterm Examination Introduction to Computer Science II (ITI 1121) Midterm Examination Instructor: Marcel Turcotte February 2008, duration: 2 hours Identification Student name: Student number: Signature: Instructions 1. 2.

More information

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. QUEEN'S UNIVERSITY SCHOOL OF COMPUTING HAND IN Answers Are Recorded on Question Paper CISC124, WINTER TERM, 2012 FINAL EXAMINATION 9am to 12pm, 26 APRIL 2012 Instructor: Alan McLeod If the instructor is

More information

University of Cape Town Department of Computer Science. Computer Science CSC115F. June 2003/2004 Supplementary Exam

University of Cape Town Department of Computer Science. Computer Science CSC115F. June 2003/2004 Supplementary Exam University of Cape Town Department of Computer Science Computer Science CSC115F June 2003/2004 Supplementary Exam Answer all questions. All questions that refer to elements of programming make reference

More information

ESC101 : Fundamental of Computing

ESC101 : Fundamental of Computing ESC101 : Fundamental of Computing End Semester Exam 19 November 2008 Name : Roll No. : Section : Note : Read the instructions carefully 1. You will lose 3 marks if you forget to write your name, roll number,

More information

ASSIGNMENT 5 Objects, Files, and a Music Player

ASSIGNMENT 5 Objects, Files, and a Music Player ASSIGNMENT 5 Objects, Files, and a Music Player COMP-202A, Fall 2009, All Sections Due: Thursday, December 3, 2009 (23:55) You MUST do this assignment individually and, unless otherwise specified, you

More information

Final Exam Computer Programming 230 Dr. St. John Lehman College City University of New York Thursday, 20 May 2010

Final Exam Computer Programming 230 Dr. St. John Lehman College City University of New York Thursday, 20 May 2010 Final Exam Computer Programming 230 Dr. St. John Lehman College City University of New York Thursday, 20 May 2010 NAME (Printed) NAME (Signed) E-mail Exam Rules Show all your work. Your grade will be based

More information

Advanced Internet Programming CSY3020

Advanced Internet Programming CSY3020 Advanced Internet Programming CSY3020 Java Applets The three Java Applet examples produce a very rudimentary drawing applet. An Applet is compiled Java which is normally run within a browser. Java applets

More information

Instruction to students:

Instruction to students: Benha University 2 nd Term (2012) Final Exam Class: 2 nd Year Students Subject: Object Oriented Programming Faculty of Computers & Informatics Date: 20/5/2012 Time: 3 hours Examiner: Dr. Essam Halim Instruction

More information

TA office hours are over after this week, but Dan and Maja will still be around for the next month

TA office hours are over after this week, but Dan and Maja will still be around for the next month TA office hours are over after this week, but Dan and Maja will still be around for the next month Feel free to e-mail me to request an appointment. My schedule is flexible. We will have more office hours

More information

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

Introduction This assignment will ask that you write a simple graphical user interface (GUI). Computing and Information Systems/Creative Computing University of London International Programmes 2910220: Graphical Object-Oriented and Internet programming in Java Coursework one 2011-12 Introduction

More information

Core Competency DOO (Design Object-Oriented)

Core Competency DOO (Design Object-Oriented) Here is the documentation for the rest of the semester. This document includes specification of the remaining Core Competencies, specifications for the final two Core Labs, and specifications for a number

More information

APCS Semester #1 Final Exam Practice Problems

APCS Semester #1 Final Exam Practice Problems Name: Date: Per: AP Computer Science, Mr. Ferraro APCS Semester #1 Final Exam Practice Problems The problems here are to get you thinking about topics we ve visited thus far in preparation for the semester

More information

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

CIS 120 Programming Languages and Techniques. Final Exam, May 3, 2011 CIS 120 Programming Languages and Techniques Final Exam, May 3, 2011 Name: Pennkey: My signature below certifies that I have complied with the University of Pennsylvania s Code of Academic Integrity in

More information

QUEEN MARY, UNIVERSITY OF LONDON DCS128 ALGORITHMS AND DATA STRUCTURES Class Test Monday 13 th February

QUEEN MARY, UNIVERSITY OF LONDON DCS128 ALGORITHMS AND DATA STRUCTURES Class Test Monday 13 th February QUEEN MARY, UNIVERSITY OF LONDON DCS128 ALGORITHMS AND DATA STRUCTURES Class Test Monday 13 th February 2006 11.05-12.35 Please fill in your Examination Number here: Student Number here: All answers to

More information

Session 04 - Object-Oriented Programming 1 Self-Assessment

Session 04 - Object-Oriented Programming 1 Self-Assessment UC3M Alberto Cortés Martín Systems Programming, 2014-2015 version: 2015-02-06 Session 04 - Object-Oriented Programming 1 Self-Assessment Exercise 1 Rectangles Part 1.A Write a class called Rectangle1 that

More information

Final Exam COMP Fall 2004 Dec 16, 2004

Final Exam COMP Fall 2004 Dec 16, 2004 1. Closed book and closed notes. Final Exam COMP 14-062 Fall 2004 Dec 16, 2004 2. Write all scratch work and answers on the exam itself. If you need extra space, let me know. Indicate your final answer

More information

Computer Science 1 Bh

Computer Science 1 Bh UNIVERSITY OF EDINBURGH course CS0077 FACULTY OF SCIENCE AND ENGINEERING DIVISION OF INFORMATICS SCHOOL OF COMPUTER SCIENCE Computer Science 1 Bh Degree Examination Date: Saturday 26th May 2001 Time: 12:00

More information

UNIT-3 : MULTI THREADED PROGRAMMING, EVENT HANDLING. A Multithreaded program contains two or more parts that can run concurrently.

UNIT-3 : MULTI THREADED PROGRAMMING, EVENT HANDLING. A Multithreaded program contains two or more parts that can run concurrently. UNIT-3 : MULTI THREADED PROGRAMMING, EVENT HANDLING 1. What are Threads? A thread is a single path of execution of code in a program. A Multithreaded program contains two or more parts that can run concurrently.

More information

Events Chris Piech CS106A, Stanford University. Piech, CS106A, Stanford University

Events Chris Piech CS106A, Stanford University. Piech, CS106A, Stanford University Events Chris Piech CS106A, Stanford University Catch Me If You Can We ve Gotten Ahead of Ourselves Source: The Hobbit Start at the Beginning Source: The Hobbit Learning Goals 1. Write a program that can

More information

Computer Science 210: Data Structures. Intro to Java Graphics

Computer Science 210: Data Structures. Intro to Java Graphics Computer Science 210: Data Structures Intro to Java Graphics Summary Today GUIs in Java using Swing in-class: a Scribbler program READING: browse Java online Docs, Swing tutorials GUIs in Java Java comes

More information

CSE 413 Winter 2001 Midterm Exam

CSE 413 Winter 2001 Midterm Exam Name ID # Score 1 2 3 4 5 6 7 8 There are 8 questions worth a total of 75 points. Please budget your time so you get to all of the questions. Keep your answers brief and to the point. You may refer to

More information

Computer Science 1 Bh

Computer Science 1 Bh UNIVERSITY OF EDINBURGH course CS0077 FACULTY OF SCIENCE AND ENGINEERING DIVISION OF INFORMATICS SCHOOL OF COMPUTER SCIENCE Computer Science 1 Bh Degree Examination Specimen Solutions Date: Saturday 26th

More information

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

Lecture 28. Exceptions and Inner Classes. Goals. We are going to talk in more detail about two advanced Java features: Lecture 28 Exceptions and Inner Classes Goals We are going to talk in more detail about two advanced Java features: Exceptions supply Java s error handling mechanism. Inner classes ease the overhead of

More information

Final Exam May 21, 2003

Final Exam May 21, 2003 1.00 Introduction to Computers and Engineering Problem Solving Final Exam May 21, 2003 Name: Email Address: TA: Section: You have three hours to complete this exam. For coding questions, you do not need

More information

Unit 7: Event driven programming

Unit 7: Event driven programming Faculty of Computer Science Programming Language 2 Object oriented design using JAVA Dr. Ayman Ezzat Email: ayman@fcih.net Web: www.fcih.net/ayman Unit 7: Event driven programming 1 1. Introduction 2.

More information

Prelim 1 Solutions. CS 2110, March 10, 2015, 5:30 PM Total Question True False. Loop Invariants Max Score Grader

Prelim 1 Solutions. CS 2110, March 10, 2015, 5:30 PM Total Question True False. Loop Invariants Max Score Grader Prelim 1 Solutions CS 2110, March 10, 2015, 5:30 PM 1 2 3 4 5 Total Question True False Short Answer Recursion Object Oriented Loop Invariants Max 20 15 20 25 20 100 Score Grader The exam is closed book

More information

Lesson 43.. ArrayList

Lesson 43.. ArrayList Lesson 43.. ArrayList 43-1 You will recall from Lesson 42 the ArrayList is one of several classes that implement the List interface. As its name suggests, ArrayList also involves arrays. Basically, everything

More information

CS/ENGRD 2110 SPRING Lecture 7: Interfaces and Abstract Classes

CS/ENGRD 2110 SPRING Lecture 7: Interfaces and Abstract Classes CS/ENGRD 2110 SPRING 2019 Lecture 7: Interfaces and Abstract Classes http://courses.cs.cornell.edu/cs2110 1 Announcements 2 A2 is due Thursday night (14 February) Go back to Lecture 6 & discuss method

More information

IT101. Graphical User Interface

IT101. Graphical User Interface IT101 Graphical User Interface Foundation Swing is a platform-independent set of Java classes used for user Graphical User Interface (GUI) programming. Abstract Window Toolkit (AWT) is an older Java GUI

More information

QUEEN MARY, UNIVERSITY OF LONDON DCS128 ALGORITHMS AND DATA STRUCTURES Class Test Monday 13 th February

QUEEN MARY, UNIVERSITY OF LONDON DCS128 ALGORITHMS AND DATA STRUCTURES Class Test Monday 13 th February QUEEN MARY, UNIVERSITY OF LONDON DCS128 ALGORITHMS AND DATA STRUCTURES Class Test Monday 13 th February 2006 11.05-12.35 Please fill in your Examination Number here: Student Number here: All answers to

More information

Instance Method Development Demo

Instance Method Development Demo Instance Method Development Demo Write a class Person with a constructor that accepts a name and an age as its argument. These values should be stored in the private attributes name and age. Then, write

More information

Computer Science II - Test 2

Computer Science II - Test 2 Computer Science II - Test 2 Question 1. (15 points) The MouseListener interface requires methods for mouseclicked, mouseentered, mouseexited, mousepressed, and mousereleased. Java s MouseAdapter implements

More information

COS 126 Midterm 1 Written Exam Fall 2011

COS 126 Midterm 1 Written Exam Fall 2011 NAME: login id: Precept: COS 126 Midterm 1 Written Exam Fall 2011 This test has 8 questions, weighted as indicated. The exam is closed book, except that you are allowed to use a one page cheatsheet. No

More information

H212 Introduction to Software Systems Honors

H212 Introduction to Software Systems Honors Introduction to Software Systems Honors Lecture #15: October 21, 2015 1/34 Generic classes and types Generic programming is the creation of programming constructs that can be usedwith many different types.

More information

AP Computer Science Unit 13. Still More Graphics and Animation.

AP Computer Science Unit 13. Still More Graphics and Animation. AP Computer Science Unit 13. Still More Graphics and Animation. In this unit you ll learn about the following: Mouse Motion Listener Suggestions for designing better graphical programs Simple game with

More information

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

ICOM 4015 Advanced Programming Laboratory. Chapter 1 Introduction to Eclipse, Java and JUnit ICOM 4015 Advanced Programming Laboratory Chapter 1 Introduction to Eclipse, Java and JUnit University of Puerto Rico Electrical and Computer Engineering Department by Juan E. Surís 1 Introduction This

More information

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

CSCI 135 Exam #1 Fundamentals of Computer Science I Fall 2012 CSCI 135 Exam #1 Fundamentals of Computer Science I Fall 2012 Name: This exam consists of 6 problems on the following 7 pages. You may use your two-sided hand-written 8 ½ x 11 note sheet during the exam.

More information