Question: 1 . Which of the following will create an array called a that contains ten integers? Select one: a. int[10] a; b. int[] a =
1. Which of the following will create an array called a that contains ten integers?
Select one:
a. int[10] a;
b. int[] a = new int[10];
c. int[] a = new[10];
d. int[] a; 2. Which of the following expressions gives the number of elements in an array a?
Select one:
a. a.size
b. a.length()
c. a.length
d. a.size() 3. Suppose that a is an array of eight elements. What is the index of the first element in a?
This question is being graded by a program. Enter an integer as your answer. Nothing more, nothing less.
___________
4.Suppose that a is an array of eight elements. What is the index of the last element in a?
This question is being graded by a program. Enter an integer as your answer. Nothing more, nothing less.
Answer:____________
5. Which of the following expressions is true if and only if an array a containing three different integers is sorted in ascending order (i.e., smallest element first)?
Select one:
a. a[1] < a[2] && a[2] < a[3]
b. a[0] < a[1] && a[1] < a[2]
c. a[1] < a[2] || a[2] < a[3]
d. a[0] < a[1] || a[1] < a[2]
6. What is the value of a[4] immediately after execution of the following three statements?
int[] a = { 8, 2, 7, 9, 5 }; a[0] = a[4]; a[4] = a[0];
Enter an integer as your answer. Nothing more, nothing less.
7.Consider the following method.
public static int f(int[] a) { int s = 0; for(int i = 1; i < a.length; i = i+2) { s = s + a[i]; } return s; }
What value is assigned to the variable x in the following code fragment?
int[] arr = { 1, 2, 3, 4, 5, 6, 7 }; int x = f(arr);
This question is being graded by a program. Enter an integer as your answer. Nothing more, nothing less.
Answer: __________
8.Consider the following method.
public static int g(int[] b) { for(int i = b.length-1; i >= 0; i--) { if(b[i] % 3 == 0) { return b[i]; } } return -1; }
What value is assigned to the variable x in the following code fragment?
int[] arr = { 1, 3, 2, 6, 8 }; int x = g(arr);
Enter an integer as your answer. Nothing more, nothing less.
Answer:_______________
9.Provide a single statement to create a two-dimensional array of integers with six rows and thirteen columns. Call the array matrix.
This question is being graded by a program. Enter the exact, case-sensitive statement as your answer. Nothing more, nothing less.
Answer: __________
10. Integer (spelled with a capital I) class is a wrapper class that takes an integer primitive and makes it an object. (We will learn more about wrapper classes later.) If you have two such objects, myInt1 and myInt2, which of its methods would you use to determine whether myInt1 is less than, greater than, or equal to myInt2?
Give nothing more than the exact, case-sensitive name of the method. This is being graded by a program!
Answer: ____________________
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
