First, the choice question
1. Define an array string[] role = {"Xue Bao Chai", "Lin Daiyu", "Jia Baoyu", "Shi Xiangyun", "Jia Chun", "Jia Spring", "Jia Tanchun"}, role[6 in the array) refers to (). C
A Jia Chun
B Jia Spring
C Jia Tanchun
D Array out of bounds
2. The following array is initialized correctly (). AB (two items selected)
A Int[] score = new INT[5];
B int score[] = new int[]{90, 12, 34, 77, 56};
C Int[] score = new int[5]{90, 12, 34, 77, 56};
D int score = {90, 12, 34, 77, 56};
3. In the following statement about arrays, the error is (). Ab
A Declare an integer array in the class as a member variable, and if it is not assigned a value, the array element value is empty.
B Arrays can store any set of data in memory space continuously
C The array must be declared before it can be used
D The array itself is an object
4. Read the following code and the output is (). B
public class demo{
double[] Price = new DOUBLE[5];
public static void Main (string[] args) {
Demo Demo = new Demo ();
Demo.price[0] = 98.10;
DEMO.PRICE[1] = 32.18;
DEMO.PRICE[2] = 77.74;
for (int i = 0; i<5; i++) {
SYSTEM.OUT.PRINTLN ((int) demo.price[i]);
}
}
}
A 98
32
78
0
0
B 98
32
77
0
0
C 98
32
78
D Compilation error
5. Read the following code, which completes the function (). B
string[] A = {" we ", " Hello ", " Creek side ", " we ", " reading "};
for (int i = 0; i < a.length; i++) {
if (a[i].equals (" we ")) {
A[i] = " they ";
}
}
A Find
B Find and replace
C Increase
D Delete
Second, simple answer
1. The 8 customers with the highest daily consumption points in a department store are: 18,25,7,36,13,2, 89, 63. Find the minimum number of integrals from this set of numbers and its original position in the array.
2. Generates an array of integers with random numbers, with 10 elements in the array, each of which has a value between 0-9 and prints the array.
Random number
Random random=new random ();
int I4=random.nextint (10);
3. The programming implementation receives a 5-bit integer from the console, using an array to determine whether the number is a palindrome.
After-school exercises in Java