Q6Sol - CSE 110: Principles of Programming withjava...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: CSE 110: Principles of Programming withjava Department of Computer Science, Arizona State University ' Spring 2009, Quiz 6 A 10 Points, 20 Minutes Student Name: ......... M I) [I point] In Java, array indexes always begin at a) -l b) 0 c) l d) 2 e) you can declare an array to have any indexes you choose 2) {I point] Which of the following statements best describes this line of code? int[} numbers = new int [50]; a) this is the declaration and initialization a ., a that holds 50 integers b) this IS a declaration and initialization of an array that holds 49 integers c) this is a declaration and initialization of an integer array that will hold integers smaller than 50 (1) this is a declaration and initialization of an integer array that will hold integers smaller than 49 6) none of the above is correct 3) [I point] Which of the statements is true about the following code snippet? int array = new int[25]; array[25] = 2; a) The integer value 2 will be assigned to the last index in the array. b) The integer value 25 will be assigned to the second index in the array. c) The integer value 25 will be assigned to the third value in the array. d) This code will r in a com ile—time error. - ‘ 15 code will result in a run-time error. 4) [1 point} What will be the output of the following code snippet? int array = new int [25}; System. out. println (array. length) ; a) 26 b) 24 @332 d) This code will result in a compile time error. me . e) This code will result in a run ti 5) [1 point] An array cannot hold object types ..................... ..(T@ Short Answer uestions: 6) [2 point] What is the output of the following program? public class Question6{ public static void main(String args) { final int SIZE=10; int[} sales = new intiSIZE]; int arrays = 0; Scanner scan = new Scanner(System.in); for{int itfl; i<SIZE;i++) saies[i] = i; for(int i=.SIZE -1; i >= 0 ; 3.49) arrays += sales[i]; —=7 6‘ Jr 3" T7 ' p ' a. o System.out.println(arrayS); } 4f 7) [3 point} Complete the following Java program that prints the content of a string in the reverse order public class Question7{ public static void main(String args) { String strl = “CSE 110 Spring 2009”; /* To Do: Write a for loop that prints the content of the string in the reverse order Hint: you can use the charAt( ) function of String data type to access each character of the String. Also, lengthO function returns the length of the string. */ ...
View Full Document

This note was uploaded on 03/10/2010 for the course MATHEMATIC 242 taught by Professor Heckman during the Spring '10 term at University of Arizona- Tucson.

Page1 / 2

Q6Sol - CSE 110: Principles of Programming withjava...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online