Module 6 quiz on arrays and parameters :Java for Android (Android App Development Specialization) Answers 2025
1. Question 1 — Correct declaration of an array of 10 objects
-
❌
Beverage[10] guestList; -
❌
Beverage guestlist = array[10]; -
✔️
Beverage[] guestList = new Beverage[10]; -
❌
new guestlist[10];
2. Question 2 — Why the code is incorrect
-
❌ setName(customer[3], “Spot”)
-
❌ all five names must be set
-
✔️ although the array of Pet references exists, none point to objects yet; each must be instantiated
-
❌ objects in array can’t be accessed individually
3. Question 3 — Arrays of objects properly created & instantiated (select all)
-
✔️ Loop version
Lesson [] week1 = new Lesson[3];
for (int i = 0; i<week1.length; i++){
week1[i] = new Lesson();
}
-
✔️ Inline initialization
Lesson [] week1 = {new Lesson(), new Lesson(), new Lesson()};
-
❌
Lesson [] week1 = new Lesson[0], new Lesson[1], new Lesson[2]; -
❌
Lesson[3] = week1[0], week1[1], week1[2];
Correct answers: Option 1 and Option 2
4. Question 4 — Why an object’s state changes when passed to a method
-
❌ the value of the object was passed
-
❌ updated when return executed
-
❌ a copy was passed
-
✔️ the reference to the object was passed
5. Question 5 — Meaning of Pet fido = sparky;
-
❌ creates new object named sparky with fido data
-
✔️ sets fido to reference (“point to”) the same object as sparky
-
❌ compares objects
-
❌ creates new object named fido
6. Question 6 — When static class constants are appropriate (select all)
-
✔️ constant used in many methods and never changes
-
✔️ constant associated with the class, accessible to clients
-
❌ variable used in different methods to avoid passing it
-
✔️ shared count across many objects (e.g. number of objects created)
Correct answers: Option 1, 2, and 4
✅ SUMMARY TABLE
| Q.No | Correct Option(s) | Answer |
|---|---|---|
| 1 | ✔️ Option 3 | Correct array declaration |
| 2 | ✔️ Option 3 | Array references not instantiated |
| 3 | ✔️ Options 1 & 2 | Proper object array creation |
| 4 | ✔️ Option 4 | Reference is passed |
| 5 | ✔️ Option 2 | fido points to sparky |
| 6 | ✔️ Options 1, 2 & 4 | Proper uses of static constants |