Question 1 of 10
A greenhouse clerk creates an array of tray counts. What text does this Java code display?
int[] trays = new int[6];
System.out.print(trays.length);
- A. 5
- B. 6
- C. 0
- D. 7
A greenhouse clerk creates an array of tray counts. What text does this Java code display?
int[] trays = new int[6];
System.out.print(trays.length);
A kiln log starts empty shelves. What text does this Java code display?
int[] shelves = new int[3];
System.out.print(shelves[0] + "," + shelves[2]);
A ferry booth records ticket leftovers with an initializer list. What text does this Java code display?
int[] tickets = {12, 8, 15, 4};
System.out.print(tickets[2]);
An orchard scale prints the last crate count. What text does this Java code display?
int[] crates = {9, 3, 7};
System.out.print(crates[crates.length - 1]);
A marina merges two slip counts into the first slot. What text does this Java code display?
int[] slips = {4, 1, 6};
slips[0] = slips[0] + slips[2];
System.out.print(slips[0] + " " + slips[1]);
A quilt booth tries to print one patch count. What happens when this Java code runs?
int[] patches = {2, 5, 8};
System.out.print(patches[patches.length]);
A weather desk lists claimed defaults after new. Which option correctly completes the three empty cells?
| Array created | Value at index 0 |
|---|---|
| new int[3] | 0 |
| new double[3] | |
| new boolean[3] | |
| new String[3] |
A kiosk stores badge labels. What text does this Java code display?
String[] badges = new String[2];
badges[1] = "gate";
System.out.print(badges[0] + " " + badges[1]);
A yarn bin array nums has already been created and has length 4. Which statement is true?
A bakery starts a pan-count array, then fills two slots. What text does this Java code display?
int[] pans = new int[4];
pans[1] = 8;
pans[3] = pans[1] + 2;
System.out.print(pans[0] + pans[1] + pans[2] + pans[3]);