6ESampleExam4_Ch6_

6ESampleExam4_Ch6_ - Name:_ Covers Chapter 6 GCIS501...

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

View Full Document Right Arrow Icon
Name:_______________________ Covers Chapter 6 GCIS501 Advanced Programming Gannon University Instructor: YK Liu (50 minutes) Part I: Multiple Choice Questions: (1 pts each) 1.Suppose array a is int[] a = {1, 2, 3}, what is a[0] - a[2]? a. 1 b. 2 c. 3 d. None of the above 2. An array reference variable can be used in which of the following ways? a. As a local variable b. As a parameter of a method c. As a return value of a method d. All of the above 3. Which of the following are valid array declarations? a. char[] charArray = new char[26]; b. int[] words = new words[10]; c. char[] charArray = "Computer Science"; d. double[3] nums = {3.5, 35.1, 32.0}; e. None of the above 4. Consider the following code fragment: int[] list = new int[10]; for (int i = 0; i <= list.length; i++) { list[i] = (int)(Math.random() * 10); } Which of the following statements is true? a. list.length must be replaced by 10 b. The loop body will execute 10 times, filling up the array with random numbers. c. The loop body will execute 10 times, filling up the array with zeros. d. The code has a runtime error indicating that the array is out of bound. 5. Assume the signature of the method xMethod is as follows. public static void xMethod(double[] a) Which of the following could be used to invoke xMethod? a. xMethod(5); 1
Background image of page 1

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

View Full DocumentRight Arrow Icon
b. xMethod({3, 4}); c. xMethod(new int[2]); d. xMethod(new double[2]); e. None of the above. 6. Given the following statement
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 7

6ESampleExam4_Ch6_ - Name:_ Covers Chapter 6 GCIS501...

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

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