Computer Applications
Given the following declarations:
final int SIZE = 20;
char[] name = new char[SIZE];
i. Write an assignment statement that stores 'D' into the first element of the array name.
ii. Write an output statement that prints the value of the tenth element of the array name.
iii. Write a for statement that fills the array name with spaces.
Java Arrays
10 Likes
Answer
i. name[0] = 'D';
ii. System.out.println(name[9]);
iii. For Statement:
for (int i = 0; i < SIZE; i++) {
name[i] = ' ';
}
Answered By
7 Likes
Related Questions
Write a code segment to compute the sum of all positive real numbers stored in the following array.
double numb[] = new double[50];
What happens in Java if you try to access an element that is outside the bounds of the array?
Write Java statements for the following:
i. Create an array to hold 15 double values.
ii. Assign the value 10.5 to the last element in the array.
iii. Display the sum of the first and the last element.
iv. Write a loop that computes the sum of all elements in the array.
Write a code segment that finds the largest integer in this two-dimensional array.
int data[][] = new int[5][5];