Which one of the following options is a valid line of code for displaying the twenty-eighth element of somearray?

Size: px
Start display at page:

Download "Which one of the following options is a valid line of code for displaying the twenty-eighth element of somearray?"

Transcription

1 2 Points / Question 1) Consider the following line of code: int[] somearray = new int[30]; Which one of the following options is a valid line of code for displaying the twenty-eighth element of somearray? a) System.out.println(somearray[28]); b) System.out.println(somearray(28)); c) System.out.println(somearray(27)); d) System.out.println(somearray[27]); Answer: d Title: Which code displays the 28th element of somearray? Difficulty: Easy Section Reference 1: 7.1 Arrays 2) Identify the correct statement for defining an integer array named numarray of ten elements. a) int[] numarray = new int[9]; b) int[] numarray = new int[10]; c) int[10] numarray; d) int numarray[10]; Title: Which statement defines integer array numarray with ten elements? Difficulty: Easy Section Reference 1: 7.1 Arrays 3) Which one of the following statements is a valid initialization of an array named somearray of ten elements? a) int[] somearray = 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 ; b) int somearray[] = 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ; c) int[10] somearray = 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 ; d) int somearray[10] = 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 ; Unit 4 - Ch 7 Test KEY Page 1 of 21

2 Title: Which array initialization statement is invalid? Section Reference 1: 7.1 Arrays 4) What is the output of the following code snippet? int[] myarray = 10, 20, 30, 40, 50 ; System.out.print(myarray[2]); System.out.print(myarray[3]); a) 1050 b) 2030 c) 3040 d) 4050 Title: What are values of the elements at the given array indexes? Section Reference 1: 7.1 Arrays 5) What is the result of executing this code snippet? int[] marks = 90, 45, 67 ; for (int i = 0; i <= 3; i++) System.out.println(marks[i]); a) The code snippet does not give any output. b) The code snippet displays all the marks stored in the array without any redundancy. c) The code snippet causes a bounds error. d) The code snippet executes an infinite loop. Title: What is output of for loop that traverses given array? Section Reference 1: 7.1 Arrays 6) Which one of the following statements is correct about the given code snippet? int[] somearray = new int[6]; for (int i = 1; i < 6; i++) Unit 4 - Ch 7 Test KEY Page 2 of 21

3 somearray[i] = i + 1; a) The for loop initializes all the elements of the array. b) The for loop initializes all the elements except the first element. c) The for loop initializes all the elements except the last element. d) The for loop initializes all the elements except the first and last elements. Title: Which statement is true about this for loop that initializes an array? Section Reference 1: 7.1 Arrays 7) What is the output of the given code snippet? int[] mynum = new int[5]; for (int i = 1; i < 5; i++) mynum[i] = i + 1; System.out.print(mynum[i]); a) 2345 b) 1234 c) 1345 d) 1111 Title: What is output of this for loop that traverses/displays array elements? Section Reference 1: 7.1 Arrays 8) What is displayed after executing the given code snippet? int[] mymarks = new int[10]; int total = 0; Scanner in = new Scanner(System.in); for (int cnt = 1; cnt <= 10; cnt++) System.out.print("Enter the marks: "); mymarks[cnt] = in.nextint(); total = total + mymarks[cnt]; System.out.println(total); a) The code snippet displays the total marks of all ten subjects. Unit 4 - Ch 7 Test KEY Page 3 of 21

4 b) The for loop causes a run-time time error on the first iteration. c) The code snippet causes a bounds error. d) The code snippet displays zero. Title: Which is result of for loop that fills an array and totals its elements? Section Reference 1: 7.1 Arrays 9) When an array myarray is only partially filled, how can the programmer keep track of the current number of elements? a) access myarray.length() b) maintain a companion variable that stores the current number of elements c) access myarray.currentelements() d) access myarray.length() - 1 Title: How is a partially filled array maintained? Difficulty: Easy Section Reference 1: 7.1 Arrays 10) In a partially filled array, the number of slots in the array that are not currently used is a) the length of the array minus the number of elements currently in the array b) the number of elements currently in the array minus the length of the array c) the length of the array plus the number of elements currently in the array d) the number of elements currently in the array Title: How do you calculate remaining space in a partially filled array? Difficulty: Easy Section Reference 1: Partially-Filled Arrays 11) What is the result of the following code? for (double element : values) element = 0; a) The elements of the array values are initialized to zero. Unit 4 - Ch 7 Test KEY Page 4 of 21

5 b) The elements of the array element are initialized to zero. c) The first element of the array values is initialized to zero. d) The array values is not modified. Ans: d Title: What is the result of the enhanced for loop? 7.2Section Reference 1: 7.2 The Enhanced for Loop 12) When the order of the elements is unimportant, what is the most efficient way to remove an element from an array? a) Delete the element and move each element after that one to a lower index. b) Replace the element to be deleted with the last element in the array. c) Replace the element to be deleted with the first element in the array. d) Replace the element with the next element. Title: What is the most efficient way to remove an element in an unordered array? Difficulty: Easy ) When an array reading and storing input runs out of space a) the program could be recompiled with a bigger size for the array. b) the array could be "grown" using the growarray method. c) it automatically resizes to accommodate new elements. d) the array could be "grown" using the new command and the copyof method. Answer: d Title: What happens when an array runs out of space? 14) It may be necessary to "grow" an array when reading inputs because a) the number of inputs may not be known in advance. b) arrays in Java must be resized after every 100 elements. c) arrays are based on powers of two. d) the only alternative is a bounds exception. Unit 4 - Ch 7 Test KEY Page 5 of 21

6 Title: Why might it be necessary to grow an array when reading inputs? 15) The binary search is faster than the linear search, providing a) the size of the array is a power of two. b) the elements of the array are ordered. c) the elements of the array are unordered. d) the element being searched for is actually in the array. Title: What is true about the binary search? Section Reference 2: Special Topic ) Which statements about array algorithms are true? I. The array algorithms are building blocks for many programs that process arrays II. Java contains ready-made array algorithms for every problem situation III. It is inefficient to make multiple passes through an array if you can do everything in one pass a) I, II b) I, III c) II, III d) I, II, III Title: Which statements about array algorithms are true? Difficulty: Easy Section Reference 1: 7.4 Problem Solving: Adapting Algorithms 17.) Suppose you wish to process an array of values and eliminate any potential duplicate values stored in the array. Which array algorithms might be adapted for this? a) find the minimum b) remove an element c) add an element d) calculate the sum of the elements Unit 4 - Ch 7 Test KEY Page 6 of 21

7 Title: Which array algorithms might be adapted to solve the "remove duplicates" problem? Section Reference 1: 7.4 Problem Solving: Adapting Algorithms 18) Which code snippet calculates the sum of all the even elements in an array values? a) int sum = 0; for (int i = 0; i < values.length; i++) if ((values[i] % 2) == 0) sum += values[i]; b) int sum = 0; for (int i = 0; i < values.length; i++) if ((values[i] % 2) == 0) sum++; c) int sum = 0; for (int i = 0; i < values.length; i++) if ((values[i] / 2) == 0) sum += values[i]; d) int sum = 0; for (int i = 0; i < values.length; i++) if ((values[i] / 2) == 0) sum++; Title: Which snippet calculates the sum of elements that are even? 19) Which code snippet calculates the sum of all the elements in even positions in an array? a) int sum = 0; Unit 4 - Ch 7 Test KEY Page 7 of 21

8 for (int i = 1; i < values.length; i+=2) sum++; b) int sum = 0; for (int i = 0; i < values.length; i++) sum++; c) int sum = 0; for (int i = 0; i < values.length; i++) sum += values[i]; d) int sum = 0; for (int i = 0; i < values.length; i = i + 2) sum += values[i]; Answer: d Title: Which snippet calculates the sum of elements that are in even positions? 20) Java 7 introduced enhanced syntax for declaring array lists, which is termed a) angle brackets. b) method lists. c) diamond syntax. d) symmetric slants. Title: What is the term for the syntax Java 7 introduced for declaring array lists? Difficulty: Easy Section Reference 1: 7.7 Array Lists 21) Which statements are true regarding the differences between arrays and array lists? I. Arrays are better if the size of a collection will not change II. Array lists are more efficient than arrays III. Array lists are easier to use than arrays a) I, II b) I, III Unit 4 - Ch 7 Test KEY Page 8 of 21

9 c) II, III d) I, II, III Title: Which statements are true regarding the differences between arrays and array lists? Section Reference 1: 7.7 Array Lists 22) What is the value of the count variable after the execution of the given code snippet? ArrayList<Integer> num = new ArrayList<Integer>(); num.add(1); num.add(2); num.add(1); int count = 0; for (int i = 0; i < num.size(); i++) if (num.get(i) % 2 == 0) count++; a) 1 b) 2 c) 0 d) 3 Title: What is value of count variable after this for loop traverses the array list? Section Reference 1: 7.7 Array Lists 23) Consider the following code snippet: String[] data = "abc", "def", "ghi", "jkl" ; String [] data2; In Java 6 and later, which statement copies the data array to the data2 array? a) data2 = Arrays.copyOf(data, data2.length); b) data2 = Arrays.copyOf(data, data.length); c) data2 = Arrays.copyOf(data, data.size()); d) data2 = Arrays.copyOf(data); Title: Which code is correct to copy from one array to another? Unit 4 - Ch 7 Test KEY Page 9 of 21

10 24) Consider the following code snippet: String[] data = "123", "ghi", "jkl", "def", "%&*" ; Which statement sorts the data array in ascending order? a) data = Arrays.sort(); b) Arrays.sort(data); c) data = Arrays.sort(data.length); d) data = Arrays.sort(data); Title: Which code is correct to sort an array? 25) Consider the following method: public static int mystery(int length, int n) int[] result = new int[length]; for (int i = 0; i < result.length; i++) result[i] = (int) (n * Math.random()); return result; Which statement is correct about the code? a) The method works perfectly b) The method returns a random number c) The method return type should be changed to int[] d) The method has a bounds error when the array size is too large Title: What s true about method that uses array. Section Reference 1: 7.3 Common Array Algorithims Unit 4 - Ch 7 Test KEY Page 10 of 21

11 26) Which one of the following is the correct header for a method named arrmeth that is called like this: arrmeth(intarray); // intarray is an integer array of size 3 a) public static void arrmeth(int[] ar, int n) b) public static void arrmeth(r[], n) c) public static void arrmeth(int n, int[] ar) d) public static void arrmeth(int[] ar) Answer: d Title: Which method header is valid for the method called in this snippet? 27) Why is the following method header invalid? public static int[5] meth(int[] arr, int[] num) a) Methods that return an array cannot specify its size b) Methods cannot have an array as a return type c) Methods cannot have an array as a parameter variable d) Methods cannot have two array parameter variables Title: Why is the following method signature invalid? 28) What is the output of the following code snippet? public static void main(string[] args) String[] arr = "aaa", "bbb", "ccc" ; mystery(arr); System.out.println(arr[0] + " " + arr.length); public static void mystery(string[] arr) arr = new String[5]; arr[0] = "ddd"; a) ddd 5 b) ddd 3 c) aaa 5 d) aaa 3 Unit 4 - Ch 7 Test KEY Page 11 of 21

12 Answer: d Title: What is the output after method call that modifies array parameter variable Section Reference 1: 7.3 Common Array Algorithims 29) Consider the following code snippet. Which statement should be used to fill in the empty line so that the output will be [32, 54, 67.5, 29, 35]? public static void main(string[] args) double data[] = 32, 54, 67.5, 29, 35; System.out.println(str); a) String str = Arrays.format(data); b) String str = data.tostring(); c) String str = Arrays.toString(data); d) String str = str + ", " + data[i]; Title: What statement provides the desired output string from array 30) Select the statement that reveals the logic error in the following method. public static double minimum(double[] data) double smallest = 0.0; for (int i = 0; i < data.length; i++) if (data[i] < smallest) smallest = data[i]; return smallest; a) double m = minimum(new double[] 1.2, -3.5, 6.6, 2.4 ); b) double m = minimum(new double[] 1.2, 23.5, 16.6, ); c) double m = minimum(new double[] -10.2, 3.5, 62.6, 21.4 ); d) double m = minimum(new double[] 12.2, 31.5, 6.6, 2.4 ); Unit 4 - Ch 7 Test KEY Page 12 of 21

13 Answer: d Title: What statement reveals the logic error of a method using array Section Reference 1: 7.3 Common Array Algorithims 31) Consider the following 2-dimensional array. Select the statement that gives the number of columns in the third row. int[][] counts = 0, 0, 1, 0, 1, 1, 2, 0, 0, 1, 4, 5, 0, 2 ; a) int cols = counts[2].size(); b) int cols = counts.length[2]; c) int cols = counts.length; d) int cols = counts[2].length; Answer: d Title: What statement gives the column size of a 2-dimensional array 32) Consider the following code snippet: int cnt = 0; int[][] numarray = new int[2][3]; for (int i = 0; i < 3; i++) for (int j = 0; j < 2; j++) numarray[j][i] = cnt; cnt++; What is the value of numarray[1][2] after the code snippet is executed? a) 2 b) 5 c) 3 d) 4 Unit 4 - Ch 7 Test KEY Page 13 of 21

14 Title: What is the value of this 2-dimension array element after the nested for loop is executed? 33) Which one of the following statements is the correct definition for a two-dimensional array of 20 rows and 2 columns of the type integer? a) int[][] num = new int[20][2]; b) int[][] num = new int[2][20]; c) int[][] num = new int[20,2]; d) int[][] num = new int[2,20]; Title: Which is correct definition for a 2D integer array of 20 rows and 2 columns? 34) Consider the following code snippet: int[][] numarray = 3, 2, 3, 0, 0, 0 ; System.out.print(numarray[0][0]); System.out.print(numarray[1][0]); What is the output of the given code snippet? a) 00 b) 31 c) 30 d) 03 Title: What is output of snippet that initializes 2-dimensional array and displays two of its elements? 35) Which one of the following statements is correct for displaying the value in the second row and the third column of a two-dimensional, size 3 by 4 array? a) System.out.println(arr[1][2]); b) System.out.println(arr[2][3]); Unit 4 - Ch 7 Test KEY Page 14 of 21

15 c) System.out.println(arr[2][1]); d) System.out.println(arr[3][2]); Title: Which statement displays the value in the second row and third column of a 2-dimensional 3 by 4 array? 36) Consider the following code snippet: ArrayList<Integer> num1 = new ArrayList<Integer>(); int data; Scanner in = new Scanner(System.in); for (int i = 0; i < 5; i++) data = in.nextint(); num1.add(data); if (data == 0 && num1.size() > 3) num1.remove(num1.size() - 1); System.out.println("size is : " + num1.size()); What is the output of the given code snippet if the user enters 1,2,0,0,1 as the input? a) size is : 1 b) size is : 2 c) size is : 4 d) size is : 0 Title: What is the size of the array list after for loop with given input values? Section Reference 1: 7.7 Array Lists 37) What is the output of the following code snippet? ArrayList<Integer> num; num.add(4); System.out.println(num.size()); a) 1 b) 0 c) 4 d) Error because num is not initialized Unit 4 - Ch 7 Test KEY Page 15 of 21

16 Answer: d Title: What is value of array list.size after this snippet with add()? Difficulty: Easy Section Reference 1: 7.7 Array Lists 38) What is the value of the cnt variable after the execution of the code snippet below? ArrayList<Integer> somenum = new ArrayList<Integer>(); somenum.add(1); somenum.add(2); somenum.add(1); int cnt = 0; for (int index = 0; index < somenum.size(); index++) if (somenum.get(index) % 2 == 0) cnt++; a) 1 b) 2 c) 3 d) 0 Title: What is value of cnt variable after this for loop traverses the array list? Section Reference 1: 7.7 Array Lists 39) What is the value of myarray[1][2] after this code snippet is executed? int count = 0; int[][] myarray = new int[4][5]; for (int i = 0; i < 5; i++) for (int j = 0; j < 4; j++) myarray[j][i] = count; count++; a) 8 b) 9 c) 19 d) 11 Title: What is the value of this 2-dimensional array element after the nested for loop is executed? Unit 4 - Ch 7 Test KEY Page 16 of 21

17 40) What is the output of the code snippet below? int[][] numarray = 8, 7, 6, 0, 0, 0 ; System.out.print(numarray[0][0]); System.out.print(numarray[1][0]); a) 00 b) 87 c) 80 d) 08 Title: What is output of snippet that initializes 2-dimensional array and displays two of its elements? 41) Consider the following code snippet: int[][] arr = 1, 2, 3, 0, 4, 5, 6, 0, 0, 0, 0, 0 ; int[][] arr2 = arr; System.out.println(arr2[2][1] + arr2[1][2]); What is the output of the given code snippet on execution? a) 5 b) 6 c) 7 d) 9 Title: What is the output of this snippet that sums two values in a copied 2-dimensional array reference? 42) What should you check for when calculating the smallest value in an array list? Unit 4 - Ch 7 Test KEY Page 17 of 21

18 a) The array list contains at least one element. b) The array list contains at least two elements. c) The array list contains the maximum value in the first element. d) The array list contains the minimum value in the first element. Title: What should be checked when calculating the smallest value in an array list? Difficulty: Easy Section Reference 1: 7.7 Array Lists 43) Which one of the following is the correct code snippet for calculating the largest value in an integer array list alist? a) int max = 0; for (int count = 1; count < alist.size(); count++) if (alist.get(count) > max) max = alist.get(count); b) int max = alist.get(0); for (int count = 1; count < alist.size(); count++) if (alist.get(count) > max) max = alist.get(count); c) int max = alist[1]; for (int count = 1; count < alist.size(); count++) if (alist.get(count) > max) max = alist.get(count); d) int max = alist.get(0); for (int count = 1; count > alist.size(); count++) if (alist.get(count) >= max) max = alist.get(count); Title: Which is correct code for calculating the largest value in array list of size 6? Section Reference 1: 7.7 Array Lists Unit 4 - Ch 7 Test KEY Page 18 of 21

19 44) What is the output of the following code? int[][] counts = 0, 0, 1, 0, 1, 1, 2, 0, 0, 1, 4, 5, 0, 2 ; System.out.println(counts[3].length); a) 2 b) 3 c) 4 d) 5 Title: What is the output of the code with a 2-dimensional array having different column sizes 45) Assume the following variable has been declared and given a value as shown: int[] numbers = 9, 17, -4, 21 ; Which is the value of numbers.length? a)3 b)4 c)9 d)21 Title: Which is the value of numbers.length 46) Assume the variable numbers has been declared to be an array that has at least one element. Which is the following represents the last element in numbers? a)numbers[numbers.length] b)numbers.length c)numbers[ 1] d)numbers[numbers.length 1] Answer: d Unit 4 - Ch 7 Test KEY Page 19 of 21

20 Title: Which is the following represents the last element in numbers 47) What will be printed by the statements below? int[] values = 1, 2, 3, 4; values[2] = 24; values[values[0]] = 86; for (int i = 0; i < values.length; i++) System.out.print (values[i] + " "); a) b) c) d) Title: What will be printed by the statements below 48) What will be printed by the statements below? int[] values = 4, 5, 6, 7; for (int i = 1; i < values.length; i++) values[i] = values[i 1] + values[i]; for (int i = 0; i < values.length; i++) System.out.print (values[i] + " "); a) b) c) d) Title: What will be printed by the statements below Unit 4 - Ch 7 Test KEY Page 20 of 21

21 49) What will be printed by the statements below? int[] values = 4, 5, 6, 7; values[0] = values[3]; values[3] = values[0]; for (int i = 0; i < values.length; i++) System.out.print (values[i] + " "); a) b) c) d) Title: What will be printed by the statements below 50) What will be printed by the statements below? a)0 b)1 c)2 d)3 int[] values = 10, 24, 3, 64; int position = 0; for (int i = 1; i < values.length; i++) if (values[i] > values[position]) position = i; System.out.print (position); Answer: d Title: What will be printed by the statements below Unit 4 - Ch 7 Test KEY Page 21 of 21

AP Computer Science Java Mr. Clausen Program 9A, 9B

AP Computer Science Java Mr. Clausen Program 9A, 9B AP Computer Science Java Mr. Clausen Program 9A, 9B PROGRAM 9A I m_sort_of_searching (20 points now, 60 points when all parts are finished) The purpose of this project is to set up a program that will

More information

CS 141: Introduction to (Java) Programming: Exam 1 Jenny Orr Willamette University Fall 2013

CS 141: Introduction to (Java) Programming: Exam 1 Jenny Orr Willamette University Fall 2013 Oct 4, 2013, p 1 Name: CS 141: Introduction to (Java) Programming: Exam 1 Jenny Orr Willamette University Fall 2013 1. (max 18) 4. (max 16) 2. (max 12) 5. (max 12) 3. (max 24) 6. (max 18) Total: (max 100)

More information

System.out.println("\nEnter Product Number 1-5 (0 to stop and view summary) :

System.out.println(\nEnter Product Number 1-5 (0 to stop and view summary) : Benjamin Michael Java Homework 3 10/31/2012 1) Sales.java Code // Sales.java // Program calculates sales, based on an input of product // number and quantity sold import java.util.scanner; public class

More information

In this Chapter you ll learn:

In this Chapter you ll learn: Now go, write it before them in a table, and note it in a book. Isaiah 30:8 To go beyond is as wrong as to fall short. Confucius Begin at the beginning, and go on till you come to the end: then stop. Lewis

More information

MIDTERM 1 REVIEW WRITING CODE POSSIBLE SOLUTION

MIDTERM 1 REVIEW WRITING CODE POSSIBLE SOLUTION MIDTERM 1 REVIEW WRITING CODE POSSIBLE SOLUTION 1. Write a loop that computes (No need to write a complete program) 100 1 99 2 98 3 97... 4 3 98 2 99 1 100 Note: this is not the only solution; double sum

More information

MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question.

MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question. Exam Name MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question. 1) The JDK command to compile a class in the file Test.java is A) java Test.java B) java

More information

1) Which of the following is a constant, according to Java naming conventions? a. PI b. Test c. x d. radius

1) Which of the following is a constant, according to Java naming conventions? a. PI b. Test c. x d. radius Programming Concepts Practice Test 1 1) Which of the following is a constant, according to Java naming conventions? a. PI b. Test c. x d. radius 2) Consider the following statement: System.out.println("1

More information

Basics of Java Programming Input and the Scanner class

Basics of Java Programming Input and the Scanner class Basics of Java Programming Input and the Scanner class CSC 1051 Algorithms and Data Structures I Dr. Mary-Angela Papalaskari Department of Computing Sciences Villanova University Course website: www.csc.villanova.edu/~map/1051/

More information

Arrays. number: Motivation. Prof. Stewart Weiss. Software Design Lecture Notes Arrays

Arrays. number: Motivation. Prof. Stewart Weiss. Software Design Lecture Notes Arrays Motivation Suppose that we want a program that can read in a list of numbers and sort that list, or nd the largest value in that list. To be concrete about it, suppose we have 15 numbers to read in from

More information

Building Java Programs

Building Java Programs Building Java Programs Chapter 3 Lecture 3-3: Interactive Programs w/ Scanner reading: 3.3-3.4 self-check: #16-19 exercises: #11 videos: Ch. 3 #4 Interactive programs We have written programs that print

More information

D06 PROGRAMMING with JAVA

D06 PROGRAMMING with JAVA Cicles Formatius de Grau Superior Desenvolupament d Aplicacions Informàtiques D06 PROGRAMMING with JAVA Ch8 Arrays and Array Lists PowerPoint presentation, created by Angel A. Juan - ajuanp(@)gmail.com,

More information

JAVA ARRAY EXAMPLE PDF

JAVA ARRAY EXAMPLE PDF JAVA ARRAY EXAMPLE PDF Created By: Umar Farooque Khan 1 Java array example for interview pdf Program No: 01 Print Java Array Example using for loop package ptutorial; public class PrintArray { public static

More information

Arrays in Java. Working with Arrays

Arrays in Java. Working with Arrays Arrays in Java So far we have talked about variables as a storage location for a single value of a particular data type. We can also define a variable in such a way that it can store multiple values. Such

More information

Chapter 2: Elements of Java

Chapter 2: Elements of Java Chapter 2: Elements of Java Basic components of a Java program Primitive data types Arithmetic expressions Type casting. The String type (introduction) Basic I/O statements Importing packages. 1 Introduction

More information

CSE 1223: Introduction to Computer Programming in Java Chapter 2 Java Fundamentals

CSE 1223: Introduction to Computer Programming in Java Chapter 2 Java Fundamentals CSE 1223: Introduction to Computer Programming in Java Chapter 2 Java Fundamentals 1 Recall From Last Time: Java Program import java.util.scanner; public class EggBasket { public static void main(string[]

More information

LOOPS CHAPTER CHAPTER GOALS

LOOPS CHAPTER CHAPTER GOALS jfe_ch04_7.fm Page 139 Friday, May 8, 2009 2:45 PM LOOPS CHAPTER 4 CHAPTER GOALS To learn about while, for, and do loops To become familiar with common loop algorithms To understand nested loops To implement

More information

Building Java Programs

Building Java Programs Building Java Programs Chapter 3 Lecture 3-3: Interactive Programs w/ Scanner reading: 3.3-3.4 self-check: #16-19 exercises: #11 videos: Ch. 3 #4 Interactive programs We have written programs that print

More information

CMSC 202H. ArrayList, Multidimensional Arrays

CMSC 202H. ArrayList, Multidimensional Arrays CMSC 202H ArrayList, Multidimensional Arrays What s an Array List ArrayList is a class in the standard Java libraries that can hold any type of object an object that can grow and shrink while your program

More information

Pseudo code Tutorial and Exercises Teacher s Version

Pseudo code Tutorial and Exercises Teacher s Version Pseudo code Tutorial and Exercises Teacher s Version Pseudo-code is an informal way to express the design of a computer program or an algorithm in 1.45. The aim is to get the idea quickly and also easy

More information

Two-Dimensional Arrays. 15-110 Summer 2010 Margaret Reid-Miller

Two-Dimensional Arrays. 15-110 Summer 2010 Margaret Reid-Miller Two-Dimensional Arrays 15-110 Margaret Reid-Miller Two-Dimensional Arrays Arrays that we have consider up to now are onedimensional arrays, a single line of elements. Often data come naturally in the form

More information

AP Computer Science Static Methods, Strings, User Input

AP Computer Science Static Methods, Strings, User Input AP Computer Science Static Methods, Strings, User Input Static Methods The Math class contains a special type of methods, called static methods. A static method DOES NOT operate on an object. This is because

More information

Object-Oriented Programming in Java

Object-Oriented Programming in Java CSCI/CMPE 3326 Object-Oriented Programming in Java Class, object, member field and method, final constant, format specifier, file I/O Dongchul Kim Department of Computer Science University of Texas Rio

More information

Building Java Programs

Building Java Programs Building Java Programs Chapter 5 Lecture 5-2: Random Numbers reading: 5.1-5.2 self-check: #8-17 exercises: #3-6, 10, 12 videos: Ch. 5 #1-2 1 The Random class A Random object generates pseudo-random* numbers.

More information

Introduction to Programming

Introduction to Programming Introduction to Programming Lecturer: Steve Maybank Department of Computer Science and Information Systems sjmaybank@dcs.bbk.ac.uk Spring 2015 Week 2b: Review of Week 1, Variables 16 January 2015 Birkbeck

More information

Introduction to Java

Introduction to Java Introduction to Java The HelloWorld program Primitive data types Assignment and arithmetic operations User input Conditional statements Looping Arrays CSA0011 Matthew Xuereb 2008 1 Java Overview A high

More information

This loop prints out the numbers from 1 through 10 on separate lines. How does it work? Output: 1 2 3 4 5 6 7 8 9 10

This loop prints out the numbers from 1 through 10 on separate lines. How does it work? Output: 1 2 3 4 5 6 7 8 9 10 Java Loops & Methods The while loop Syntax: while ( condition is true ) { do these statements Just as it says, the statements execute while the condition is true. Once the condition becomes false, execution

More information

Section IV.1: Recursive Algorithms and Recursion Trees

Section IV.1: Recursive Algorithms and Recursion Trees Section IV.1: Recursive Algorithms and Recursion Trees Definition IV.1.1: A recursive algorithm is an algorithm that solves a problem by (1) reducing it to an instance of the same problem with smaller

More information

Install Java Development Kit (JDK) 1.8 http://www.oracle.com/technetwork/java/javase/downloads/index.html

Install Java Development Kit (JDK) 1.8 http://www.oracle.com/technetwork/java/javase/downloads/index.html CS 259: Data Structures with Java Hello World with the IntelliJ IDE Instructor: Joel Castellanos e-mail: joel.unm.edu Web: http://cs.unm.edu/~joel/ Office: Farris Engineering Center 319 8/19/2015 Install

More information

Masters programmes in Computer Science and Information Systems. Object-Oriented Design and Programming. Sample module entry test xxth December 2013

Masters programmes in Computer Science and Information Systems. Object-Oriented Design and Programming. Sample module entry test xxth December 2013 Masters programmes in Computer Science and Information Systems Object-Oriented Design and Programming Sample module entry test xxth December 2013 This sample paper has more questions than the real paper

More information

Translating to Java. Translation. Input. Many Level Translations. read, get, input, ask, request. Requirements Design Algorithm Java Machine Language

Translating to Java. Translation. Input. Many Level Translations. read, get, input, ask, request. Requirements Design Algorithm Java Machine Language Translation Translating to Java Introduction to Computer Programming The job of a programmer is to translate a problem description into a computer language. You need to be able to convert a problem description

More information

Two-Dimensional Arrays. Multi-dimensional Arrays. Two-Dimensional Array Indexing

Two-Dimensional Arrays. Multi-dimensional Arrays. Two-Dimensional Array Indexing Multi-dimensional Arrays The elements of an array can be any type Including an array type So int 2D[] []; declares an array of arrays of int Two dimensional arrays are useful for representing tables of

More information

J a v a Quiz (Unit 3, Test 0 Practice)

J a v a Quiz (Unit 3, Test 0 Practice) Computer Science S-111a: Intensive Introduction to Computer Science Using Java Handout #11 Your Name Teaching Fellow J a v a Quiz (Unit 3, Test 0 Practice) Multiple-choice questions are worth 2 points

More information

Topic 11 Scanner object, conditional execution

Topic 11 Scanner object, conditional execution Topic 11 Scanner object, conditional execution "There are only two kinds of programming languages: those people always [complain] about and those nobody uses." Bjarne Stroustroup, creator of C++ Copyright

More information

Designing with Exceptions. CSE219, Computer Science III Stony Brook University http://www.cs.stonybrook.edu/~cse219

Designing with Exceptions. CSE219, Computer Science III Stony Brook University http://www.cs.stonybrook.edu/~cse219 Designing with Exceptions CSE219, Computer Science III Stony Brook University http://www.cs.stonybrook.edu/~cse219 Testing vs. Debugging Testing Coding Does the code work properly YES NO 2 Debugging Testing

More information

COMPUTER SCIENCE. Paper 1 (THEORY)

COMPUTER SCIENCE. Paper 1 (THEORY) COMPUTER SCIENCE Paper 1 (THEORY) (Three hours) Maximum Marks: 70 (Candidates are allowed additional 15 minutes for only reading the paper. They must NOT start writing during this time) -----------------------------------------------------------------------------------------------------------------------

More information

Efficient Data Structures for Decision Diagrams

Efficient Data Structures for Decision Diagrams Artificial Intelligence Laboratory Efficient Data Structures for Decision Diagrams Master Thesis Nacereddine Ouaret Professor: Supervisors: Boi Faltings Thomas Léauté Radoslaw Szymanek Contents Introduction...

More information

One Dimension Array: Declaring a fixed-array, if array-name is the name of an array

One Dimension Array: Declaring a fixed-array, if array-name is the name of an array Arrays in Visual Basic 6 An array is a collection of simple variables of the same type to which the computer can efficiently assign a list of values. Array variables have the same kinds of names as simple

More information

Classes and Objects in Java Constructors. In creating objects of the type Fraction, we have used statements similar to the following:

Classes and Objects in Java Constructors. In creating objects of the type Fraction, we have used statements similar to the following: In creating objects of the type, we have used statements similar to the following: f = new (); The parentheses in the expression () makes it look like a method, yet we never created such a method in our

More information

Arrays. Atul Prakash Readings: Chapter 10, Downey Sun s Java tutorial on Arrays: http://java.sun.com/docs/books/tutorial/java/nutsandbolts/arrays.

Arrays. Atul Prakash Readings: Chapter 10, Downey Sun s Java tutorial on Arrays: http://java.sun.com/docs/books/tutorial/java/nutsandbolts/arrays. Arrays Atul Prakash Readings: Chapter 10, Downey Sun s Java tutorial on Arrays: http://java.sun.com/docs/books/tutorial/java/nutsandbolts/arrays.html 1 Grid in Assignment 2 How do you represent the state

More information

8.1. Example: Visualizing Data

8.1. Example: Visualizing Data Chapter 8. Arrays and Files In the preceding chapters, we have used variables to store single values of a given type. It is sometimes convenient to store multiple values of a given type in a single collection

More information

1.4 Arrays Introduction to Programming in Java: An Interdisciplinary Approach Robert Sedgewick and Kevin Wayne Copyright 2002 2010 2/6/11 12:33 PM!

1.4 Arrays Introduction to Programming in Java: An Interdisciplinary Approach Robert Sedgewick and Kevin Wayne Copyright 2002 2010 2/6/11 12:33 PM! 1.4 Arrays Introduction to Programming in Java: An Interdisciplinary Approach Robert Sedgewick and Kevin Wayne Copyright 2002 2010 2/6/11 12:33 PM! A Foundation for Programming any program you might want

More information

Arrays. Introduction. Chapter 7

Arrays. Introduction. Chapter 7 CH07 p375-436 1/30/07 1:02 PM Page 375 Chapter 7 Arrays Introduction The sequential nature of files severely limits the number of interesting things you can easily do with them.the algorithms we have examined

More information

JAVA - METHODS. Method definition consists of a method header and a method body. The same is shown below:

JAVA - METHODS. Method definition consists of a method header and a method body. The same is shown below: http://www.tutorialspoint.com/java/java_methods.htm JAVA - METHODS Copyright tutorialspoint.com A Java method is a collection of statements that are grouped together to perform an operation. When you call

More information

Lab Experience 17. Programming Language Translation

Lab Experience 17. Programming Language Translation Lab Experience 17 Programming Language Translation Objectives Gain insight into the translation process for converting one virtual machine to another See the process by which an assembler translates assembly

More information

PES Institute of Technology-BSC QUESTION BANK

PES Institute of Technology-BSC QUESTION BANK PES Institute of Technology-BSC Faculty: Mrs. R.Bharathi CS35: Data Structures Using C QUESTION BANK UNIT I -BASIC CONCEPTS 1. What is an ADT? Briefly explain the categories that classify the functions

More information

File class in Java. Scanner reminder. Files 10/19/2012. File Input and Output (Savitch, Chapter 10)

File class in Java. Scanner reminder. Files 10/19/2012. File Input and Output (Savitch, Chapter 10) File class in Java File Input and Output (Savitch, Chapter 10) TOPICS File Input Exception Handling File Output Programmers refer to input/output as "I/O". The File class represents files as objects. The

More information

Searching Algorithms

Searching Algorithms Searching Algorithms The Search Problem Problem Statement: Given a set of data e.g., int [] arr = {10, 2, 7, 9, 7, 4}; and a particular value, e.g., int val = 7; Find the first index of the value in the

More information

You are to simulate the process by making a record of the balls chosen, in the sequence in which they are chosen. Typical output for a run would be:

You are to simulate the process by making a record of the balls chosen, in the sequence in which they are chosen. Typical output for a run would be: Lecture 7 Picking Balls From an Urn The problem: An urn has n (n = 10) balls numbered from 0 to 9 A ball is selected at random, its' is number noted, it is set aside, and another ball is selected from

More information

Introduction to Java Applications. 2005 Pearson Education, Inc. All rights reserved.

Introduction to Java Applications. 2005 Pearson Education, Inc. All rights reserved. 1 2 Introduction to Java Applications 2.2 First Program in Java: Printing a Line of Text 2 Application Executes when you use the java command to launch the Java Virtual Machine (JVM) Sample program Displays

More information

CSE 2123 Collections: Sets and Iterators (Hash functions and Trees) Jeremy Morris

CSE 2123 Collections: Sets and Iterators (Hash functions and Trees) Jeremy Morris CSE 2123 Collections: Sets and Iterators (Hash functions and Trees) Jeremy Morris 1 Collections - Set What is a Set? A Set is an unordered sequence of data with no duplicates Not like a List where you

More information

Software Testing. Definition: Testing is a process of executing a program with data, with the sole intention of finding errors in the program.

Software Testing. Definition: Testing is a process of executing a program with data, with the sole intention of finding errors in the program. Software Testing Definition: Testing is a process of executing a program with data, with the sole intention of finding errors in the program. Testing can only reveal the presence of errors and not the

More information

1) The postfix expression for the infix expression A+B*(C+D)/F+D*E is ABCD+*F/DE*++

1) The postfix expression for the infix expression A+B*(C+D)/F+D*E is ABCD+*F/DE*++ Answer the following 1) The postfix expression for the infix expression A+B*(C+D)/F+D*E is ABCD+*F/DE*++ 2) Which data structure is needed to convert infix notations to postfix notations? Stack 3) The

More information

10CS35: Data Structures Using C

10CS35: Data Structures Using C CS35: Data Structures Using C QUESTION BANK REVIEW OF STRUCTURES AND POINTERS, INTRODUCTION TO SPECIAL FEATURES OF C OBJECTIVE: Learn : Usage of structures, unions - a conventional tool for handling a

More information

Iteration CHAPTER 6. Topic Summary

Iteration CHAPTER 6. Topic Summary CHAPTER 6 Iteration TOPIC OUTLINE 6.1 while Loops 6.2 for Loops 6.3 Nested Loops 6.4 Off-by-1 Errors 6.5 Random Numbers and Simulations 6.6 Loop Invariants (AB only) Topic Summary 6.1 while Loops Many

More information

Answers to Review Questions Chapter 7

Answers to Review Questions Chapter 7 Answers to Review Questions Chapter 7 1. The size declarator is used in a definition of an array to indicate the number of elements the array will have. A subscript is used to access a specific element

More information

DATA STRUCTURES USING C

DATA STRUCTURES USING C DATA STRUCTURES USING C QUESTION BANK UNIT I 1. Define data. 2. Define Entity. 3. Define information. 4. Define Array. 5. Define data structure. 6. Give any two applications of data structures. 7. Give

More information

Partitioning under the hood in MySQL 5.5

Partitioning under the hood in MySQL 5.5 Partitioning under the hood in MySQL 5.5 Mattias Jonsson, Partitioning developer Mikael Ronström, Partitioning author Who are we? Mikael is a founder of the technology behind NDB

More information

Chapter 5. Recursion. Data Structures and Algorithms in Java

Chapter 5. Recursion. Data Structures and Algorithms in Java Chapter 5 Recursion Data Structures and Algorithms in Java Objectives Discuss the following topics: Recursive Definitions Method Calls and Recursion Implementation Anatomy of a Recursive Call Tail Recursion

More information

Scanner. It takes input and splits it into a sequence of tokens. A token is a group of characters which form some unit.

Scanner. It takes input and splits it into a sequence of tokens. A token is a group of characters which form some unit. Scanner The Scanner class is intended to be used for input. It takes input and splits it into a sequence of tokens. A token is a group of characters which form some unit. For example, suppose the input

More information

Conditionals (with solutions)

Conditionals (with solutions) Conditionals (with solutions) For exercises 1 to 27, indicate the output that will be produced. Assume the following declarations: final int MAX = 25, LIMIT = 100; int num1 = 12, num2 = 25, num3 = 87;

More information

A binary search tree or BST is a binary tree that is either empty or in which the data element of each node has a key, and:

A binary search tree or BST is a binary tree that is either empty or in which the data element of each node has a key, and: Binary Search Trees 1 The general binary tree shown in the previous chapter is not terribly useful in practice. The chief use of binary trees is for providing rapid access to data (indexing, if you will)

More information

Using Files as Input/Output in Java 5.0 Applications

Using Files as Input/Output in Java 5.0 Applications Using Files as Input/Output in Java 5.0 Applications The goal of this module is to present enough information about files to allow you to write applications in Java that fetch their input from a file instead

More information

Semantic Analysis: Types and Type Checking

Semantic Analysis: Types and Type Checking Semantic Analysis Semantic Analysis: Types and Type Checking CS 471 October 10, 2007 Source code Lexical Analysis tokens Syntactic Analysis AST Semantic Analysis AST Intermediate Code Gen lexical errors

More information

Data Structures. Algorithm Performance and Big O Analysis

Data Structures. Algorithm Performance and Big O Analysis Data Structures Algorithm Performance and Big O Analysis What s an Algorithm? a clearly specified set of instructions to be followed to solve a problem. In essence: A computer program. In detail: Defined

More information

WESTMORELAND COUNTY PUBLIC SCHOOLS 2011 2012 Integrated Instructional Pacing Guide and Checklist Computer Math

WESTMORELAND COUNTY PUBLIC SCHOOLS 2011 2012 Integrated Instructional Pacing Guide and Checklist Computer Math Textbook Correlation WESTMORELAND COUNTY PUBLIC SCHOOLS 2011 2012 Integrated Instructional Pacing Guide and Checklist Computer Math Following Directions Unit FIRST QUARTER AND SECOND QUARTER Logic Unit

More information

CSE 1223: Introduction to Computer Programming in Java Chapter 7 File I/O

CSE 1223: Introduction to Computer Programming in Java Chapter 7 File I/O CSE 1223: Introduction to Computer Programming in Java Chapter 7 File I/O 1 Sending Output to a (Text) File import java.util.scanner; import java.io.*; public class TextFileOutputDemo1 public static void

More information

PA2: Word Cloud (100 Points)

PA2: Word Cloud (100 Points) PA2: Word Cloud (100 Points) Due: 11:59pm, Thursday, April 16th Overview You will create a program to read in a text file and output the most frequent and unique words by using an ArrayList. Setup In all

More information

Database Programming with PL/SQL: Learning Objectives

Database Programming with PL/SQL: Learning Objectives Database Programming with PL/SQL: Learning Objectives This course covers PL/SQL, a procedural language extension to SQL. Through an innovative project-based approach, students learn procedural logic constructs

More information

Scanner sc = new Scanner(System.in); // scanner for the keyboard. Scanner sc = new Scanner(System.in); // scanner for the keyboard

Scanner sc = new Scanner(System.in); // scanner for the keyboard. Scanner sc = new Scanner(System.in); // scanner for the keyboard INPUT & OUTPUT I/O Example Using keyboard input for characters import java.util.scanner; class Echo{ public static void main (String[] args) { Scanner sc = new Scanner(System.in); // scanner for the keyboard

More information

Chapter 2: Algorithm Discovery and Design. Invitation to Computer Science, C++ Version, Third Edition

Chapter 2: Algorithm Discovery and Design. Invitation to Computer Science, C++ Version, Third Edition Chapter 2: Algorithm Discovery and Design Invitation to Computer Science, C++ Version, Third Edition Objectives In this chapter, you will learn about: Representing algorithms Examples of algorithmic problem

More information

COMPUTER SCIENCE 1999 (Delhi Board)

COMPUTER SCIENCE 1999 (Delhi Board) COMPUTER SCIENCE 1999 (Delhi Board) Time allowed: 3 hours Max. Marks: 70 Instructions: (i) All the questions are compulsory. (ii) Programming Language: C++ QUESTION l. (a) Why main function is special?

More information

Software Engineering Techniques

Software Engineering Techniques Software Engineering Techniques Low level design issues for programming-in-the-large. Software Quality Design by contract Pre- and post conditions Class invariants Ten do Ten do nots Another type of summary

More information

Solving Problems Recursively

Solving Problems Recursively Solving Problems Recursively Recursion is an indispensable tool in a programmer s toolkit Allows many complex problems to be solved simply Elegance and understanding in code often leads to better programs:

More information

Symbol Tables. Introduction

Symbol Tables. Introduction Symbol Tables Introduction A compiler needs to collect and use information about the names appearing in the source program. This information is entered into a data structure called a symbol table. The

More information

qwertyuiopasdfghjklzxcvbnmqwerty uiopasdfghjklzxcvbnmqwertyuiopasd fghjklzxcvbnmqwertyuiopasdfghjklzx cvbnmqwertyuiopasdfghjklzxcvbnmq

qwertyuiopasdfghjklzxcvbnmqwerty uiopasdfghjklzxcvbnmqwertyuiopasd fghjklzxcvbnmqwertyuiopasdfghjklzx cvbnmqwertyuiopasdfghjklzxcvbnmq qwertyuiopasdfghjklzxcvbnmqwerty uiopasdfghjklzxcvbnmqwertyuiopasd fghjklzxcvbnmqwertyuiopasdfghjklzx cvbnmqwertyuiopasdfghjklzxcvbnmq Introduction to Programming using Java wertyuiopasdfghjklzxcvbnmqwertyui

More information

AP Computer Science Java Subset

AP Computer Science Java Subset APPENDIX A AP Computer Science Java Subset The AP Java subset is intended to outline the features of Java that may appear on the AP Computer Science A Exam. The AP Java subset is NOT intended as an overall

More information

COSC 1020 3.0 Introduction to Computer Science I Section A, Summer 2005. Question Out of Mark A Total 16. B-1 7 B-2 4 B-3 4 B-4 4 B Total 19

COSC 1020 3.0 Introduction to Computer Science I Section A, Summer 2005. Question Out of Mark A Total 16. B-1 7 B-2 4 B-3 4 B-4 4 B Total 19 Term Test #2 COSC 1020 3.0 Introduction to Computer Science I Section A, Summer 2005 Family Name: Given Name(s): Student Number: Question Out of Mark A Total 16 B-1 7 B-2 4 B-3 4 B-4 4 B Total 19 C-1 4

More information

Oracle Database: SQL and PL/SQL Fundamentals

Oracle Database: SQL and PL/SQL Fundamentals Oracle University Contact Us: +966 12 739 894 Oracle Database: SQL and PL/SQL Fundamentals Duration: 5 Days What you will learn This Oracle Database: SQL and PL/SQL Fundamentals training is designed to

More information

CompSci-61B, Data Structures Final Exam

CompSci-61B, Data Structures Final Exam Your Name: CompSci-61B, Data Structures Final Exam Your 8-digit Student ID: Your CS61B Class Account Login: This is a final test for mastery of the material covered in our labs, lectures, and readings.

More information

Thomas Jefferson High School for Science and Technology Program of Studies Foundations of Computer Science. Unit of Study / Textbook Correlation

Thomas Jefferson High School for Science and Technology Program of Studies Foundations of Computer Science. Unit of Study / Textbook Correlation Thomas Jefferson High School for Science and Technology Program of Studies Foundations of Computer Science updated 03/08/2012 Unit 1: JKarel 8 weeks http://www.fcps.edu/is/pos/documents/hs/compsci.htm

More information

Unit 6. Loop statements

Unit 6. Loop statements Unit 6 Loop statements Summary Repetition of statements The while statement Input loop Loop schemes The for statement The do statement Nested loops Flow control statements 6.1 Statements in Java Till now

More information

Sample CSE8A midterm Multiple Choice (circle one)

Sample CSE8A midterm Multiple Choice (circle one) Sample midterm Multiple Choice (circle one) (2 pts) Evaluate the following Boolean expressions and indicate whether short-circuiting happened during evaluation: Assume variables with the following names

More information

Curriculum Map. Discipline: Computer Science Course: C++

Curriculum Map. Discipline: Computer Science Course: C++ Curriculum Map Discipline: Computer Science Course: C++ August/September: How can computer programs make problem solving easier and more efficient? In what order does a computer execute the lines of code

More information

Computer Science III Advanced Placement G/T [AP Computer Science A] Syllabus

Computer Science III Advanced Placement G/T [AP Computer Science A] Syllabus Computer Science III Advanced Placement G/T [AP Computer Science A] Syllabus Course Overview This course is a fast-paced advanced level course that focuses on the study of the fundamental principles associated

More information

Introduction to Object-Oriented Programming

Introduction to Object-Oriented Programming Introduction to Object-Oriented Programming Programs and Methods Christopher Simpkins chris.simpkins@gatech.edu CS 1331 (Georgia Tech) Programs and Methods 1 / 8 The Anatomy of a Java Program It is customary

More information

Preet raj Core Java and Databases CS4PR. Time Allotted: 3 Hours. Final Exam: Total Possible Points 75

Preet raj Core Java and Databases CS4PR. Time Allotted: 3 Hours. Final Exam: Total Possible Points 75 Preet raj Core Java and Databases CS4PR Time Allotted: 3 Hours Final Exam: Total Possible Points 75 Q1. What is difference between overloading and overriding? 10 points a) In overloading, there is a relationship

More information

Building Java Programs

Building Java Programs Building Java Programs Chapter 4 Lecture 4-1: Scanner; if/else reading: 3.3 3.4, 4.1 Interactive Programs with Scanner reading: 3.3-3.4 1 Interactive programs We have written programs that print console

More information

Using Two-Dimensional Arrays

Using Two-Dimensional Arrays Using Two-Dimensional Arrays Great news! What used to be the old one-floor Java Motel has just been renovated! The new, five-floor Java Hotel features a free continental breakfast and, at absolutely no

More information

Unit 1. 5. Write iterative and recursive C functions to find the greatest common divisor of two integers. [6]

Unit 1. 5. Write iterative and recursive C functions to find the greatest common divisor of two integers. [6] Unit 1 1. Write the following statements in C : [4] Print the address of a float variable P. Declare and initialize an array to four characters a,b,c,d. 2. Declare a pointer to a function f which accepts

More information

Chapter 3. Input and output. 3.1 The System class

Chapter 3. Input and output. 3.1 The System class Chapter 3 Input and output The programs we ve looked at so far just display messages, which doesn t involve a lot of real computation. This chapter will show you how to read input from the keyboard, use

More information

Moving from CS 61A Scheme to CS 61B Java

Moving from CS 61A Scheme to CS 61B Java Moving from CS 61A Scheme to CS 61B Java Introduction Java is an object-oriented language. This document describes some of the differences between object-oriented programming in Scheme (which we hope you

More information

D06 PROGRAMMING with JAVA

D06 PROGRAMMING with JAVA Cicles Formatius de Grau Superior Desenvolupament d Aplicacions Informàtiques D06 PROGRAMMING with JAVA Ch20 Data Structures I PowerPoint presentation, created by Angel A. Juan - ajuanp(@)gmail.com, for

More information

Mobile App Design Project #1 Java Boot Camp: Design Model for Chutes and Ladders Board Game

Mobile App Design Project #1 Java Boot Camp: Design Model for Chutes and Ladders Board Game Mobile App Design Project #1 Java Boot Camp: Design Model for Chutes and Ladders Board Game Directions: In mobile Applications the Control Model View model works to divide the work within an application.

More information

QUIZ-II QUIZ-II. Chapter 5: Control Structures II (Repetition) Objectives. Objectives (cont d.) 20/11/2015. EEE 117 Computer Programming Fall-2015 1

QUIZ-II QUIZ-II. Chapter 5: Control Structures II (Repetition) Objectives. Objectives (cont d.) 20/11/2015. EEE 117 Computer Programming Fall-2015 1 QUIZ-II Write a program that mimics a calculator. The program should take as input two integers and the operation to be performed. It should then output the numbers, the operator, and the result. (For

More information

Chapter 7: Sequential Data Structures

Chapter 7: Sequential Data Structures Java by Definition Chapter 7: Sequential Data Structures Page 1 of 112 Chapter 7: Sequential Data Structures We have so far explored the basic features of the Java language, including an overview of objectoriented

More information

Introduction to Pig. Content developed and presented by: 2009 Cloudera, Inc.

Introduction to Pig. Content developed and presented by: 2009 Cloudera, Inc. Introduction to Pig Content developed and presented by: Outline Motivation Background Components How it Works with Map Reduce Pig Latin by Example Wrap up & Conclusions Motivation Map Reduce is very powerful,

More information

GRID SEARCHING Novel way of Searching 2D Array

GRID SEARCHING Novel way of Searching 2D Array GRID SEARCHING Novel way of Searching 2D Array Rehan Guha Institute of Engineering & Management Kolkata, India Abstract: Linear/Sequential searching is the basic search algorithm used in data structures.

More information

Arrays in Java. data in bulk

Arrays in Java. data in bulk Arrays in Java data in bulk Array Homogeneous collection of elements all same data type can be simple type or object type Each element is accessible via its index (random access) Arrays are, loosely speaking,

More information

Analysis of Binary Search algorithm and Selection Sort algorithm

Analysis of Binary Search algorithm and Selection Sort algorithm Analysis of Binary Search algorithm and Selection Sort algorithm In this section we shall take up two representative problems in computer science, work out the algorithms based on the best strategy to

More information

Specimen 2015 am/pm Time allowed: 1hr 30mins

Specimen 2015 am/pm Time allowed: 1hr 30mins SPECIMEN MATERIAL GCSE COMPUTER SCIENCE 8520/1 Paper 1 Specimen 2015 am/pm Time allowed: 1hr 30mins Materials There are no additional materials required for this paper. Instructions Use black ink or black

More information