CS-259 Computer Programming Fundamentals Arrays
|
|
- Rebecca O’Connor’
- 5 years ago
- Views:
Transcription
1 CS-9 Computer Programming Fundamentals Arrays int a = new int[]; Instructor: Joel Castellanos joel@unm.edu And in such indexes, although small pricks To their subsequent volumes, there is seen The baby figure of the giant mas Of things to come at large. --William Shakespeare, Troilus and Cressida //6 Textbook & Reading Assignment Introduction to java Programming ( th Edition) by Y. Daniel Liang Read by Wednesday: Sept 8 Chapter 7: Arrays Sections through. Study Questions: 7., 7.6, 7.7, 7.8, 7. Read by Friday: Sept Chapter 7: Arrays Sections 6 through end of chapter.
2 An Index (plural: indexes) In publishing, an index is a list of words or phrases, "headings", and associated pointers "locators" to where useful material relating to that heading can be found in a document. In a traditional back-of-the-book index, the headings will include names of people, places and events, and concepts selected by a person as being relevant and of interest to a possible reader of the book. The pointers are typically page numbers, paragraph numbers or section numbers. In a library catalog the words are authors, titles, subject headings, etc., and the pointers are call numbers. The Array 4 In Java, an array is collection of data items allocated in sequential memory locations that can be selected by indices computed at run-time. ) int[] a; ) int[] b = {,,,, }; ) int[] c = new int[]; 4) c[767] = 9; ) a = b; 6) System.out.println(a[i]); No matter how large an array, a particular element can be loaded or stored in constant time. a b c
3 Arrays: Fibonacci Series ) //Example without an array ) int f = ; ) int f = ; 4) int f = f + f; ) int f = f + f; 6) int f4 = f + f; 7) int f = f4 + f; 8) int f6 = f + f4; 9) ) System.out.println(f + " " + f + " " ) + f + " " + f + " " + f4 + " " + f ) + " " + f6); ) 4) // 8 Arrays: Fibonacci Series 6 ) //Example with an array ) int[] f = new int[7]; ) f[] = ; 4) f[] = ; ) f[] = f[] + f[]; 6) f[] = f[] + f[]; 7) f[4] = f[] + f[]; 8) f[] = f[4] + f[]; 9) f[6] = f[] + f[4]; ). int[] f declares f as a reference to an int array.. f = new int[7] reserves memory for 7 int variables and sets f to reference that block of memory. ) System.out.println(f[] + " " + f[] ) + " " + f[] + " " + f[] + " " + f[4] ) + " " + f[] + " " + f[6]); 4) // 8
4 Array Versatility: Fibonacci Series 7 ) //Example array In Java, arrays ) int[] f = new int[4]; hava a field ) f[] = ;.length not a method 4) f[] = ;.length(). ) for (int i=; i<f.length; i++) 6) { f[i] = f[i-] + f[i-]; By contrast, a 7) } String has a 8) method.length() not 9) for (int i=; i<f.length; i++) a field.length. ) { System.out.print(f[i] + " "); ) } ) System.out.println(); ) 4) // Quiz: Arrays and Fibonacci Series In the Java code below, which lines can be swapped (have their positions interchanged) without causing an error or changing the output? ) int[] f = new int[6]; ) f[] = ; ) f[] = ; 4) for (int i=; i<f.length; i++) ) { 6) System.out.println(f[i-]); 7) f[i] = f[i-] + f[i-]; 8) } 8 a) & b) & 4 c) 4 & d) 4 & 6 e) 6 & 7 4
5 Helper Method: printarray ) public static void printarray(int[] array) ) { ) System.out.print("{ "); 4) for (int i=; i<array.length; i++) ) { 6) System.out.print(array[i] +" "); 7) } 8) System.out.println("}"); 9) } Why make this public? 9 Quiz: find max ) int[] numlist = {,,,,, }; ) ) int max = numlist[]; 4) for (int i=; i<numlist.length; i++) ) { if (numlist[i] > max) 6) { System.out.print(max+" "); 7) max=numlist[i]; 8) } 9) } ) System.out.println(); max= max = max= What is the output of the above code segment? a) b) c) d) e)
6 Find The Syntax Error ) int[] numlist = {,,,,, }; ) ) int max = numlist; 4) Type mismatch: Cannot Convert form int[] to int ) 6) for (int i=; i<numlist.length; i++) 7) { 8) if (numlist[i] > max) 9) { ) System.out.print(max+" "); ) max=numlist[i]; ) } )} 4)System.out.println(); Quiz: find max ) int[] numlist = {, 7,, 7, 8}; ) ) int max = numlist[]; 4) for (int i=; i<numlist.length; i++) ) { System.out.print(i + "(" +max+") "); 6) if (numlist[i] > max) 7) { max=numlist[i]; 8) } 9) } ) System.out.println(); What is the output of the above code segment? a) () (7) () (7) 4(8) b) () (7) () 4(7) (8) c) () (7) () 4(8) d) () () () 4(7) e) () () () 4() 6
7 Array Reference Copy ) public static void main(string[] args) ) { int[] a = {,,,, }; ) int[] b = a; 4) b[] = ; ) System.out.println( 6) a[] + ", " + a[] + ", " + b[]); 7) } Line Line Line 4 a a b a b Array Element Copy 4 ) public static void main(string[] args) ) { int[] a = {,,,, }; ) int[] b = new int[]; 4) for (i=; i<a.length; i++) ) { b[i]=a[i]; 6) } 7) b[] = 8; 8) System.out.println( 9) a[] + ", " + a[] + ", " + b[]); ) } a b a b 8 7
8 Quiz: Array Copying. public static void main(string[] args). { int[] a = {,,,,, 8};. int[] b = a; 4. b[] = 7;. System.out.println( 6. a[] + ", " + a[] + ", " + b[]); 7. } The output is: a) 7, 7, 7 b), 7, 7 c),, 7 d),, 7 e),, Allocating Space for Arrays of Objects 6 ) //Allocates space for three -bit integers. ) int[] x = new int[]; ) 4) //Allocates space for three references. ) JFrame[] frames = new JFrame[]; 6) 7) for (int i = ; i<; i++) 8) { 9) x[i] = i; ) JFrame constructor NOT called. JFrame constructor IS called. ) //Create each of the JFrame instances. ) p[i] = new JFrame(); ) frames[i].setbounds(i*,i*,, ); 4) frames[i].setvisible(true); ) } Without line, line will cause a Null Pointer Exception. 8
9 7 Comparing Array References. public static void main(string[] args). { int[] a = {,,,, 7};. int[] b = {,,,, 7}; 4. if (a==b). { System.out.println("yes"); 6. } 7. else System.out.println("no"); 8. } Output: no a 7 b 7 Quiz: On Which line is the Syntax Error? public class SyntaxQuiz { public static double abs(double a) { if (a <.) return -a; return a; } 8 public static void main(string[] args) { double[] x = {., -.4, 7.}; int i = ; a) System.out.println(abs(x[])); b) System.out.println(abs(x[i])); c) System.out.println(abs(x)); d) System.out.println(abs(i)); e) System.out.println(abs(x[] - x[])); } } 9
10 BouncingLines 9 ) Start with BouncingLine.java. ) BouncingLine.java uses int x, y, x, y to maintain the location of the line's two endpoints. ) Transform BouncingLine.java to use arrays int[] x, y, x, y to maintain a history of the line's endpoints. 4) After drawing NUM_LINES, each time step, erase the oldest line in the history and replace it with the line's new location. BouncingLines: imports ) import java.awt.color; ) import java.awt.graphics; ) import java.awt.event.actionevent; 4) import java.awt.event.actionlistener; ) import java.util.random; 6) import javax.swing.timer;
11 BouncingLines: Class and Instance Fields ) public class BouncingLines implements ActionListener ) { ) private Random rand = new Random(); 4) private Timer mytimer; ) private Picture mypic; 6) private Graphics canvas; 7) 8) private static final int DRAW_WIDTH = 6; 9) private static final int DRAW_HEIGHT = 6; ) private static final int NUM_LINES = ; ) ) private int[] x = new int[num_lines]; ) private int[] x = new int[num_lines]; Parallel 4) private int[] y = new int[num_lines]; Arrays ) private int[] y = new int[num_lines]; 6) private int curidx = ; 7) 8) private int speedx, speedx, speedy, speedy; Data Structure: Circular, Parallel Arrays private int[] x = new int[num_lines]; private int[] x = new int[num_lines]; private int[] y = new int[num_lines]; private int[] y = new int[num_lines]; x y x y Newest line Oldest Line curidx nextidx
12 BouncingLines: main public static void main(string[] args) { new BouncingLines(); } 4 BouncingLines: Constructor ) public BouncingLines() ) { ) mypic = new Picture(DRAW_WIDTH, DRAW_HEIGHT); ) canvas = mypic.getoffscreengraphics(); 4) canvas.setcolor(color.white); ) canvas.fillrect(,, DRAW_WIDTH, DRAW_HEIGHT); 6) mypic.settitle("bounding Lines"); 7) 8) x[] = rand.nextint(draw_width); 9) y[] = rand.nextint(draw_height); ) x[] = rand.nextint(draw_width); ) y[] = rand.nextint(draw_height); ) ) speedx = rand.nextint()-; 4) speedy = rand.nextint()-; ) speedx = rand.nextint()-; 6) speedy = rand.nextint()-; 7) 8) mytimer = new Timer(, this); // miliseconds 9) mytimer.start(); 4) }
13 BouncingLines: actionperformed ( of ) ) public void actionperformed(actionevent arg) ) { ) //Let nextidx be the index of the oldest line. ) int nextidx = (curidx+) % NUM_LINES; ) //Erase oldest line. 6) //Move newest line and store its endpoints at index where // the oldest line was stored. 7) //If next line is out of bounds in the horizontal direction, then // give it a random horizontal speed in the opposite direction. //If next line is out of bounds in the vertical direction, then // give it a random vertical speed in the opposite direction. 9) //Update the current line index. 9) //Draw the new line 99) } BouncingLines: actionperformed ( of ) ) public void actionperformed(actionevent arg) ) { ) //Let nextidx be the index of the oldest line. ) int nextidx = (curidx+) % NUM_LINES; 4) ) //Erase oldest line. 6) canvas.setcolor(color.white); 7) canvas.drawline(x[nextidx], y[nextidx], 8) x[nextidx], y[nextidx]); 6
14 BouncingLines: actionperformed ( of ) 6) //Move newest line and store its endpoints at index 6) // where the oldest line was stored. 6) x[nextidx] = x[curidx] + speedx; 6) y[nextidx] = y[curidx] + speedy; 64) 6) x[nextidx] = x[curidx] + speedx; 66) y[nextidx] = y[curidx] + speedy; 67) 68) 7 BouncingLines: actionperformed (4 of ) 7) //If next line is out of bounds in the horizontal direction, then 7) // give it a random horizontal speed in the opposite direction. 7) //If next line is out of bounds in the vertical direction, then 7) // give it a random vertical speed in the opposite direction. 74) if (x[nextidx] < ) speedx = rand.nextint()+; 7) if (y[nextidx] < ) speedy = rand.nextint()+; 76) 77) if (x[nextidx]>draw_width) speedx =-(rand.nextint()+); 78) if (y[nextidx]>draw_height) speedy=-(rand.nextint()+); 79) 8) 8) 8) if (x[nextidx] < ) speedx = rand.nextint()+; 8) if (y[nextidx] < ) speedy = rand.nextint()+; 84) 8) if (x[nextidx]>draw_width) speedx =-(rand.nextint()+); 86) if (y[nextidx]>draw_height) speedy=-(rand.nextint()+); 87) 8 4
15 BouncingLines: actionperformed ( of ) 9) //Update the current line index. 9) curidx = nextidx; 9) 9) //Draw the new line 94) canvas.setcolor(color.red); 9) canvas.drawline(x[curidx], y[curidx], 96) x[curidx], y[curidx]); 97) mypic.repaint(); 98) 99)} 9
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 CMPE212, FALL TERM, 2012 FINAL EXAMINATION 18 December 2012, 2pm Instructor: Alan McLeod If the instructor is unavailable
More informationCSC 160 LAB 8-1 DIGITAL PICTURE FRAME. 1. Introduction
CSC 160 LAB 8-1 DIGITAL PICTURE FRAME PROFESSOR GODFREY MUGANDA DEPARTMENT OF COMPUTER SCIENCE 1. Introduction Download and unzip the images folder from the course website. The folder contains 28 images
More information15. Arrays and Methods. Java. Summer 2008 Instructor: Dr. Masoud Yaghini
15. Java Summer 2008 Instructor: Dr. Masoud Yaghini Outline Passing Arrays to Methods Returning an Array from a Method Variable-Length Argument Lists References Passing Arrays to Methods Passing Arrays
More informationSpring University of New Mexico CS152 Midterm Exam. Print Your Name
Print Your Name You may use one page of hand written notes (both sides) and a dictionary. No i-phones, calculators or any other type of non-organic computer. Do not take this exam if you are sick. Once
More informationCMP 326 Midterm Fall 2015
CMP 326 Midterm Fall 2015 Name: 1) (30 points; 5 points each) Write the output of each piece of code. If the code gives an error, write any output that would happen before the error, and then write ERROR.
More information1.00/1.001 Introduction to Computers and Engineering Problem Solving Fall (total 7 pages)
1.00/1.001 Introduction to Computers and Engineering Problem Solving Fall 2002 (total 7 pages) Name: TA s Name: Tutorial: For Graders Question 1 Question 2 Question 3 Total Problem 1 (20 points) True or
More informationClasses and Objects 3/28/2017. How can multiple methods within a Java class read and write the same variable?
Peer Instruction 8 Classes and Objects How can multiple methods within a Java class read and write the same variable? A. Allow one method to reference a local variable of the other B. Declare a variable
More informationCS 152 Computer Programming Fundamentals The if-else Statement
CS 152 Computer Programming Fundamentals The if-else Statement Instructor: Joel Castellanos e-mail: joel@unm.edu Web: http://cs.unm.edu/~joel/ Office: Electrical and Computer Engineering building (ECE).
More informationGive one example where you might wish to use a three dimensional array
CS 110: INTRODUCTION TO COMPUTER SCIENCE SAMPLE TEST 3 TIME ALLOWED: 60 MINUTES Student s Name: MAXIMUM MARK 100 NOTE: Unless otherwise stated, the questions are with reference to the Java Programming
More informationPractice 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 informationMidterm I - CSE11 Fall 2013 CLOSED BOOK, CLOSED NOTES 50 minutes, 100 points Total.
Midterm I - CSE11 Fall 2013 CLOSED BOOK, CLOSED NOTES 50 minutes, 100 points Total. Name: ID: Problem 1) (8 points) For the following code segment, what are the values of i, j, k, and d, after the segment
More informationFirst Exam Computer Programming 326 Dr. St. John Lehman College City University of New York Thursday, 7 October 2010
First Exam Computer Programming 326 Dr. St. John Lehman College City University of New York Thursday, 7 October 2010 NAME (Printed) NAME (Signed) E-mail Exam Rules Show all your work. Your grade will be
More informationNested Loops. A loop can be nested inside another loop.
Nested Loops A loop can be nested inside another loop. Nested loops consist of an outer loop and one or more inner loops. Each time the outer loop is repeated, the inner loops are reentered, and started
More informationC212 Early Evaluation Exam Mon Feb Name: Please provide brief (common sense) justifications with your answers below.
C212 Early Evaluation Exam Mon Feb 10 2014 Name: Please provide brief (common sense) justifications with your answers below. 1. What is the type (and value) of this expression: 5 * (7 + 4 / 2) 2. What
More informationProctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.
SOLUTION HAND IN Answers Are Recorded on Question Paper QUEEN'S UNIVERSITY SCHOOL OF COMPUTING CISC212, FALL TERM, 2006 FINAL EXAMINATION 7pm to 10pm, 19 DECEMBER 2006, Jeffrey Hall 1 st Floor Instructor:
More informationSampleApp.java. Page 1
SampleApp.java 1 package msoe.se2030.sequence; 2 3 /** 4 * This app creates a UI and processes data 5 * @author hornick 6 */ 7 public class SampleApp { 8 private UserInterface ui; // the UI for this program
More informationOverview. Lecture 7: Inheritance and GUIs. Inheritance. Example 9/30/2008
Overview Lecture 7: Inheritance and GUIs Written by: Daniel Dalevi Inheritance Subclasses and superclasses Java keywords Interfaces and inheritance The JComponent class Casting The cosmic superclass Object
More informationPractice 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 information1.00 Introduction to Computers and Engineering Problem Solving. Quiz 1 March 7, 2003
1.00 Introduction to Computers and Engineering Problem Solving Quiz 1 March 7, 2003 Name: Email Address: TA: Section: You have 90 minutes to complete this exam. For coding questions, you do not need to
More informationCSC 1051 Algorithms and Data Structures I. Final Examination May 12, Name
CSC 1051 Algorithms and Data Structures I Final Examination May 12, 2017 Name Question Value Score 1 10 2 10 3 10 4 10 5 10 6 10 7 10 8 10 9 10 10 10 TOTAL 100 Please answer questions in the spaces provided.
More informationProctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.
HAND IN Answers Are Recorded on Question Paper QUEEN'S UNIVERSITY SCHOOL OF COMPUTING CISC212, FALL TERM, 2006 FINAL EXAMINATION 7pm to 10pm, 19 DECEMBER 2006, Jeffrey Hall 1 st Floor Instructor: Alan
More information(A) 99 (B) 100 (C) 101 (D) 100 initial integers plus any additional integers required during program execution
Ch 5 Arrays Multiple Choice 01. An array is a (A) (B) (C) (D) data structure with one, or more, elements of the same type. data structure with LIFO access. data structure, which allows transfer between
More information1.00 Introduction to Computers and Engineering Problem Solving Quiz 1 March 4, 2005
1.00 Introduction to Computers and Engineering Problem Solving Quiz 1 March 4, 2005 Name: E-mail Address: TA: Section: You have 80 minutes to complete this exam. For coding questions, you do not need to
More informationComputer 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 informationThe design of an ADT should evolve naturally during the problem-solving process Questions to ask when designing an ADT
Designing an ADT The design of an ADT should evolve naturally during the problem-solving process Questions to ask when designing an ADT What data does a problem require? What operations does a problem
More informationChapter 5 Names, Bindings, Type Checking, and Scopes
Chapter 5 Names, Bindings, Type Checking, and Scopes Names Variables The Concept of Binding Scope and Lifetime Type Checking Referencing Environments Named Constants Names Used for variables, subprograms
More informationAnswer on question #61311, Programming & Computer Science / Java
Answer on question #61311, Programming & Computer Science / Java JSP JSF for completion Once the user starts the thread by clicking a button, the program must choose a random image out of an image array,
More informationExample: Building a Java GUI
Steven Zeil October 25, 2013 Contents 1 Develop the Model 2 2 Develop the layout of those elements 3 3 Add listeners to the elements 9 4 Implement custom drawing 12 1 The StringArt Program To illustrate
More informationAP 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 informationComputer Science II (20082) Week 1: Review and Inheritance
Computer Science II 4003-232-08 (20082) Week 1: Review and Inheritance Richard Zanibbi Rochester Institute of Technology Review of CS-I Syntax and Semantics of Formal (e.g. Programming) Languages Syntax
More informationExample: Building a Java GUI
Steven Zeil October 25, 2013 Contents 1 Develop the Model 3 2 Develop the layout of those elements 4 3 Add listeners to the elements 12 4 Implement custom drawing 15 1 The StringArt Program To illustrate
More informationCOMPUTER APPLICATIONS
COMPUTER APPLICATIONS (Theory) (Two hours) Answers to this Paper must be written on the paper provided separately. You will not be allowed to write during the first 15 minutes. This time is to be spent
More informationUniversity of Cape Town ~ Department of Computer Science. Computer Science 1016S / 1011H ~ January Exam
Name: Please fill in your Student Number and Name. Student Number : Student Number: University of Cape Town ~ Department of Computer Science Computer Science 1016S / 1011H ~ 2009 January Exam Question
More informationCS 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 informationUse the Scantron sheets to write your answer. Make sure to write your Purdue ID (NOT Purdue Login ID) and your name on the Scantron answer sheet.
Department of Computer Science Purdue University, West Lafayette Fall 2011: CS 180 Problem Solving and OO Programming Final Examination: Part A. You may consult the textbook and your hand written notes.
More informationAP Computer Science Chapter 10 Implementing and Using Classes Study Guide
AP Computer Science Chapter 10 Implementing and Using Classes Study Guide 1. A class that uses a given class X is called a client of X. 2. Private features of a class can be directly accessed only within
More informationName Section Number. CS110 Exam #1 *** PLEASE TURN OFF ALL CELLPHONES ***
Name Section Number CS110 Exam #1 *** PLEASE TURN OFF ALL CELLPHONES *** Sections: All Practice Bob Wilson You may use your crib sheet only (one HANDWRITTEN 8-1/2 x 11 page both sides). You will have all
More informationMore About Classes CS 1025 Computer Science Fundamentals I Stephen M. Watt University of Western Ontario
More About Classes CS 1025 Computer Science Fundamentals I Stephen M. Watt University of Western Ontario The Story So Far... Classes as collections of fields and methods. Methods can access fields, and
More informationCS 231 Data Structures and Algorithms Fall Event Based Programming Lecture 06 - September 17, Prof. Zadia Codabux
CS 231 Data Structures and Algorithms Fall 2018 Event Based Programming Lecture 06 - September 17, 2018 Prof. Zadia Codabux 1 Agenda Event-based Programming Misc. Java Operator Precedence Java Formatting
More informationLecture 17. Instructor: Craig Duckett. Passing & Returning Arrays
Lecture 17 Instructor: Craig Duckett Passing & Returning Arrays Assignment Dates (By Due Date) Assignment 1 (LECTURE 5) GRADED! Section 1: Monday, January 22 nd Assignment 2 (LECTURE 8) GRADED! Section
More information1. 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 informationCS111: PROGRAMMING LANGUAGE II
CS111: PROGRAMMING LANGUAGE II Computer Science Department Lecture 1(c): Java Basics (II) Lecture Contents Java basics (part II) Conditions Loops Methods Conditions & Branching Conditional Statements A
More informationif (x == 0); System.out.println( x=0 ); if (x = 0) System.out.println( x=0 );
Sample Final Exam 1. Evaluate each of the following expressions and show the result and data type of each: Expression Value Data Type 14 % 5 1 / 2 + 1 / 3 + 1 / 4 4.0 / 2.0 Math.pow(2.0, 3.0) (double)(2
More information(A) 99 ** (B) 100 (C) 101 (D) 100 initial integers plus any additional integers required during program execution
Ch 5 Arrays Multiple Choice Test 01. An array is a ** (A) data structure with one, or more, elements of the same type. (B) data structure with LIFO access. (C) data structure, which allows transfer between
More informationMr. Monroe s Guide to Mastering Java Syntax
Mr. Monroe s Guide to Mastering Java Syntax Getting Started with Java 1. Download and install the official JDK (Java Development Kit). 2. Download an IDE (Integrated Development Environment), like BlueJ.
More informationCOMP16121 Notes on Mock Exam Questions
COMP16121 Notes on Mock Exam Questions December 2016 Mock Exam Attached you will find a Mock multiple choice question (MCQ) exam for COMP16121, to assist you in preparing for the actual COMP16121 MCQ Exam
More informationRAIK 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 informationPage 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.
Page 1 of 16 HAND IN Answers Are Recorded on Question Paper QUEEN'S UNIVERSITY SCHOOL OF COMPUTING CISC212, FALL TERM, 2005 FINAL EXAMINATION 9am to 12noon, 19 DECEMBER 2005 Instructor: Alan McLeod If
More informationANSWER KEY First Exam Computer Programming 326 Dr. St. John Lehman College City University of New York Thursday, 7 October 2010
ANSWER KEY First Exam Computer Programming 326 Dr. St. John Lehman College City University of New York Thursday, 7 October 2010 1. True or False: (a) T An algorithm is a a set of directions for solving
More informationCS 101 Fall 2006 Midterm 3 Name: ID:
You only need to write your name and e-mail ID on the first page. This exam is CLOSED text book, closed-notes, closed-calculator, closed-neighbor, etc. Questions are worth different amounts, so be sure
More informationCS 134 Programming Exercise 7:
CS 134 Programming Exercise 7: Scribbler Objective: To gain more experience using recursion and recursive data structures. This week, you will be implementing a program we call Scribbler. You have seen
More informationCS 351 Design of Large Programs
CS 351 Design of Large Programs Code Standards Instructor: Joel Castellanos e-mail: joel@unm.edu Web: http://cs.unm.edu/~joel/ Office: Farris Engineering Center (FEC) room 319 1/17/2017 Why Do All Cars
More informationJava-Array. This tutorial introduces how to declare array variables, create arrays, and process arrays using indexed variables.
-Array Java provides a data structure, the array, which stores a fixed-size sequential collection of elements of the same type. An array is used to store a collection of data, but it is often more useful
More informationCS-257L Nonimperative Programming: Scheme!
CS-257L Nonimperative Programming: Scheme! Instructor: Joel Castellanos e-mail: joel@unm.edu Web: http://cs.unm.edu/~joel/ Office: Farris Engineering Center (FEC room 321 Scheme Vectors Vectors applied
More informationQueens College, CUNY Department of Computer Science. CS 212 Object-Oriented Programming in Java Practice Exam 2. CS 212 Exam 2 Study Guide
Topics for Exam 2: Queens College, CUNY Department of Computer Science CS 212 Object-Oriented Programming in Java Practice Exam 2 CS 212 Exam 2 Study Guide Linked Lists define a list node define a singly-linked
More informationG51PGP Programming Paradigms. Lecture 008 Inner classes, anonymous classes, Swing worker thread
G51PGP Programming Paradigms Lecture 008 Inner classes, anonymous classes, Swing worker thread 1 Reminder subtype polymorphism public class TestAnimals public static void main(string[] args) Animal[] animals
More informationMIT AITI Swing Event Model Lecture 17
MIT AITI 2004 Swing Event Model Lecture 17 The Java Event Model In the last lecture, we learned how to construct a GUI to present information to the user. But how do GUIs interact with users? How do applications
More informationUNIT 3 ARRAYS, RECURSION, AND COMPLEXITY CHAPTER 10 INTRODUCTION TO ARRAYS
UNIT 3 ARRAYS, RECURSION, AND COMPLEXITY CHAPTER 10 INTRODUCTION TO ARRAYS EXERCISE 10.1 1. An array can contain many items and still be treated as one thing. Thus, instead of having many variables for
More informationAP Computer Science A Unit 2. Exercises
AP Computer Science A Unit 2. Exercises A common standard is 24-bit color where 8 bits are used to represent the amount of red light, 8 bits for green light, and 8 bits for blue light. It is the combination
More informationCPS109 Lab 7. Source: Big Java, Chapter 7 Preparation: read Chapter 7 and the lecture notes for this week.
1 CPS109 Lab 7 Source: Big Java, Chapter 7 Preparation: read Chapter 7 and the lecture notes for this week. Objectives: 1. To practice using one- and two-dimensional arrays 2. To practice using partially
More informationFundamentals of Object Oriented Programming
INDIAN INSTITUTE OF TECHNOLOGY ROORKEE Fundamentals of Object Oriented Programming CSN- 103 Dr. R. Balasubramanian Associate Professor Department of Computer Science and Engineering Indian Institute of
More informationArray. Array Declaration:
Array Arrays are continuous memory locations having fixed size. Where we require storing multiple data elements under single name, there we can use arrays. Arrays are homogenous in nature. It means and
More informationCSC 1051 Algorithms and Data Structures I. Final Examination May 12, Name: KEY. Question Value Score
CSC 1051 Algorithms and Data Structures I Final Examination May 12, 2017 Name: KEY Question Value Score 1 10 2 10 3 10 4 10 5 10 6 10 7 10 8 10 9 10 10 10 TOTAL 100 Please answer questions in the spaces
More informationSystems Programming. Bachelor in Telecommunication Technology Engineering Bachelor in Communication System Engineering Carlos III University of Madrid
Systems Programming Bachelor in Telecommunication Technology Engineering Bachelor in Communication System Engineering Carlos III University of Madrid Leganés, 21st of March, 2014. Duration: 75 min. Full
More informationCS 302 Week 9. Jim Williams
CS 302 Week 9 Jim Williams This Week P2 Milestone 3 Lab: Instantiating Classes Lecture: Wrapper Classes More Objects (Instances) and Classes Next Week: Spring Break Will this work? Double d = new Double(10);
More informationThe JFrame Class Frame Windows GRAPHICAL USER INTERFACES. Five steps to displaying a frame: 1) Construct an object of the JFrame class
CHAPTER GRAPHICAL USER INTERFACES 10 Slides by Donald W. Smith TechNeTrain.com Final Draft 10/30/11 10.1 Frame Windows Java provides classes to create graphical applications that can run on any major graphical
More informationUnit 10: Data Structures CS 101, Fall 2018
Unit 10: Data Structures CS 101, Fall 2018 Learning Objectives After completing this unit, you should be able to: Define and give everyday examples of arrays, stacks, queues, and trees. Explain what a
More informationCSE 142, Autumn 2008 Midterm Exam, Friday, October 31, 2008
CSE 142, Autumn 2008 Midterm Exam, Friday, October 31, 2008 Name: Section: Student ID #: TA: You have 50 minutes to complete this exam. You may receive a deduction if you keep working after the instructor
More informationThis exam is open book. Each question is worth 3 points.
This exam is open book. Each question is worth 3 points. Page 1 / 15 Page 2 / 15 Page 3 / 12 Page 4 / 18 Page 5 / 15 Page 6 / 9 Page 7 / 12 Page 8 / 6 Total / 100 (maximum is 102) 1. Are you in CS101 or
More informationRAIK 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 informationCS 61B Discussion Quiz 1. Questions
Name: SID: CS 61B Discussion Quiz 1 Write your name and SID above. Detach this page from your discussion handout, and turn it in when your TA instructs you to do so. These quizzes are used as attendance.
More informationWelcome to the Using Objects lab!
Welcome to the Using Objects lab! Learning Outcomes By the end of this lab: 1. Be able to define chapter 3 terms. 2. Describe reference variables and compare with primitive data type variables. 3. Draw
More informationBinghamton University. CS-140 Fall Problem Solving. Creating a class from scratch
Problem Solving Creating a class from scratch 1 Recipe for Writing a Class 1. Write the class boilerplate stuff 2. Declare Fields 3. Write Creator(s) 4. Write accessor methods 5. Write mutator methods
More informationFinal Exam. COMP Summer I June 26, points
Final Exam COMP 14-090 Summer I 2000 June 26, 2000 200 points 1. Closed book and closed notes. No outside material allowed. 2. Write all answers on the test itself. Do not write any answers in a blue book
More informationBuilding Java Programs
Building Java Programs Chapter 5 Random Numbers reading: 5.1, 5.6 1 http://xkcd.com/221/ 2 The while loop while loop: Repeatedly executes its body as long as a logical test is true. while (test) { statement(s);
More informationAplusBug dude = new AplusBug(); A+ Computer Science -
AplusBug dude = new AplusBug(); AplusBug dude = new AplusBug(); dude 0x234 AplusBug 0x234 dude is a reference variable that refers to an AplusBug object. A method is a storage location for related program
More informationcs Java: lecture #6
cs3101-003 Java: lecture #6 news: homework #5 due today little quiz today it s the last class! please return any textbooks you borrowed from me today s topics: interfaces recursion data structures threads
More information2 What are the differences between constructors and methods?
1 Describe the relationship between an object and its defining class. How do you define a class? How do you declare an object reference variable? How do you create an object? How do you declare and create
More informationBuilding Java Programs
Building Java Programs Chapter 8 Lecture 8-4: Static Methods and Data Critter exercise: Snake Method constructor public Snake() eat Never eats fight always forfeits getcolor black Behavior getmove 1 E,
More informationChapter 8 Objects and Classes Dr. Essam Halim Date: Page 1
Assignment (1) Chapter 8 Objects and Classes Dr. Essam Halim Date: 18-3-2014 Page 1 Section 8.2 Defining Classes for Objects 1 represents an entity in the real world that can be distinctly identified.
More informationIntroduction to Functional Programming in Java 8
1 Introduction to Functional Programming in Java 8 Java 8 is the current version of Java that was released in March, 2014. While there are many new features in Java 8, the core addition is functional programming
More informationAP 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 informationChapter 6. Arrays. Array Basics Arrays in Classes and Methods Programming with Arrays and Classes Sorting Arrays Multidimensional Arrays
Chapter 6 Arrays Array Basics Arrays in Classes and Methods Programming with Arrays and Classes Sorting Arrays Multidimensional Arrays Chapter 6 Java: an Introduction to Computer Science & Programming
More informationclass objects instances Fields Constructors Methods static
Class Structure Classes A class describes a set of objects The objects are called instances of the class A class describes: Fields (instance variables)that hold the data for each object Constructors that
More informationCPSC 219 Extra review and solutions
CPSC 219 Extra review and solutions Multiple choice questions: Unless otherwise specified assume that all necessary variable declarations have been made. For Questions 1 6 determine the output of the print()
More informationPractice Questions for Chapter 9
Practice Questions for Chapter 9 MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question. 1) An object is an instance of a. 1) A) program B) method C) class
More informationUniversity of Palestine. Mid Exam Total Grade: 100
First Question No. of Branches (5) A) Choose the correct answer: 1. If we type: system.out.println( a ); in the main() method, what will be the result? int a=12; //in the global space... void f() { int
More informationCS 211: Methods, Memory, Equality
CS 211: Methods, Memory, Equality Chris Kauffman Week 2-1 So far... Comments Statements/Expressions Variable Types little types, what about Big types? Assignment Basic Output (Input?) Conditionals (if-else)
More informationCOMP 250: Java Programming I. Carlos G. Oliver, Jérôme Waldispühl January 17-18, 2018 Slides adapted from M. Blanchette
COMP 250: Java Programming I Carlos G. Oliver, Jérôme Waldispühl January 17-18, 2018 Slides adapted from M. Blanchette Variables and types [Downey Ch 2] Variable: temporary storage location in memory.
More informationUniversity of Cape Town ~ Department of Computer Science Computer Science 1015F ~ Test 2. Question Max Mark Internal External
Name: Please fill in your Student Number and Name. Student Number : Student Number: University of Cape Town ~ Department of Computer Science Computer Science 1015F ~ 2009 Test 2 Question Max Mark Internal
More information1 Short Answer (10 Points Each)
Name: Write all of your responses on these exam pages. 1 Short Answer (10 Points Each) 1. What is the difference between a compiler and an interpreter? Also, discuss how Java accomplishes this task. 2.
More informationCS 177 Week 15 Recitation Slides. Review
CS 177 Week 15 Recitation Slides Review 1 Announcements Final Exam on Friday Dec. 18 th STEW 183 from 1 3 PM Complete your online review of your classes. Your opinion matters!!! Project 6 due Just kidding
More informationRecap: Assignment as an Operator CS 112 Introduction to Programming
Recap: Assignment as an Operator CS 112 Introduction to Programming q You can consider assignment as an operator, with a (Spring 2012) lower precedence than the arithmetic operators First the expression
More informationCourse overview: Introduction to programming concepts
Course overview: Introduction to programming concepts What is a program? The Java programming language First steps in programming Program statements and data Designing programs. This part will give an
More informationCS Week 5. Jim Williams, PhD
CS 200 - Week 5 Jim Williams, PhD The Study Cycle Check Am I using study methods that are effective? Do I understand the material enough to teach it to others? http://students.lsu.edu/academicsuccess/studying/strategies/tests/studying
More informationMethod OverLoading printf method Arrays Declaring and Using Arrays Arrays of Objects Array as Parameters
Outline Method OverLoading printf method Arrays Declaring and Using Arrays Arrays of Objects Array as Parameters Variable Length Parameter Lists split() Method from String Class Integer & Double Wrapper
More informationCSE 131 Introduction to Computer Science Fall Exam II
CSE 131 Introduction to Computer Science Fall 2013 Given: 6 November 2013 Exam II Due: End of session This exam is closed-book, closed-notes, no electronic devices allowed. The exception is the cheat sheet
More informationCSE115 / CSE503 Introduction to Computer Science I Dr. Carl Alphonce 343 Davis Hall Office hours:
CSE115 / CSE503 Introduction to Computer Science I Dr. Carl Alphonce 343 Davis Hall alphonce@buffalo.edu Office hours: Tuesday 10:00 AM 12:00 PM * Wednesday 4:00 PM 5:00 PM Friday 11:00 AM 12:00 PM OR
More informationProctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.
HAND IN Answers Are Recorded on Question Paper QUEEN'S UNIVERSITY SCHOOL OF COMPUTING CISC212, FALL TERM, 2007 FINAL EXAMINATION 7pm to 10pm, 10 DECEMBER 2007, Jeffery Hall Instructor: Alan McLeod If the
More information1 If you want to store a letter grade (like a course grade) which variable type would you use? a. int b. String c. char d. boolean
Practice Final Quiz 1 If you want to store a letter grade (like a course grade) which variable type would you use? a. int b. String c. char d. boolean 2 If you wanted to divide two numbers precisely, which
More information