For questions in my Java Programing class, I need to answer the following questi
ID: 3864421 • Letter: F
Question
For questions in my Java Programing class, I need to answer the following questions which I am not sure if I answered right:
int[] num = new int[100];
for(int i = 0; i < 50; i++)
num[i] = i;
num[5] = 10;
num[55] = 100;
1) How many components are in the array above?
(a) 0 (b) 99
(c) 50 (d) 100
2) What is the index number of the last component in the array above?
(a) 0 (b) 100
(c) 99 (d) 101
3) What is the value of num.length in the array above?
(a) 0 (b) 100
(c) 99 (d) 101
4) What is the value in index 10 of the array above?
(a) 0 (b) 10
(c) 5 (d) 50
5) Which of the following is the array subscripting operator in Java?
(a) . (b) new
(c) { } (d) [ ]
6) Assume that two arrays are parallel. Assume the first array contains a person’s id number and the second contains his or her age. In which index of the second array would you find the age of the person in the third index of the first array?
(a) 1 (b) 2
(c) 3 (d) It cannot be determined form the information given.
char[ ][ ] array1 = new char[15][10];
(7) How many dimensions are in the array above?
(a) 0 (b) 2
(c) 1 (d) 3
8) How many rows are in the array above?
(a) 0 (b) 10
(c) 2 (d) 15
9) How many columns are in the array above?
(a) 0 (b) 10
(c) 2 (d) 15
10) What is the value of array1[3].length ?
(a) 0 (b) 10
(c) 2 (d) 15
11) What is the value of array1.length ?
(a) 0 (b) 10
(c) 2 (d) 15
Explanation / Answer
1)
100 elements are there since size of array is 100 indexing 0 to 99.
2)
last element index is 99.
3) num.length is 100 as it tells the total size of array.
4) value is 10 since in for loop the value i is assigned to the ith element.And i starts from 0
5) Array subscripting operator in java is [].
6)d is correct.
7) [ ] demotes 1 dimension and [ ][ ] denotes 2 dimention. Therefore 2 dimension is answer.
8) 15 rows are there in array as length of gien array
9) 10 rows in given array.
10)15
11) 15
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.