Skip to content

Module 6 quiz on methods and classes :Java for Android (Android App Development Specialization) Answers 2025

1. Question 1 – Making instance variables private

  • ❌ is an application of security and protects against hackers

  • ❌ is an application of abstraction & protects behaviors

  • ❌ is a requirement of Java

  • ✔️ is an application of abstraction and protects against object users gaining direct access to object state.


2. Question 2 – Method that changes instance variables

  • ❌ constructor

  • ❌ default constructor

  • ❌ accessor method

  • ✔️ mutator method


3. Question 3 – Correct constructors for class Vehicle

Correct options:

  • ✔️ public Vehicle(){}

  • ✔️ public Vehicle(double mileage, int year){ this(mileage); this.year = year; }

Incorrect:

  • public void Vehicle(...) → has return type → NOT a constructor

  • public makeVehicle(...) → name mismatch

  • ❌ uses odometer = odometer; (wrong — should use this.odometer)


4. Question 4 – When a constructor is written

  • ✔️ the default constructor is no longer available

  • ✔️ the default constructor must be recreated if needed

  • ❌ the default constructor cannot be recreated

  • ❌ no other constructors can be written


5. Question 5 – Calling one constructor from another

  • ❌ two objects are created

  • ❌ class name is used

  • ❌ this must be last line

  • ✔️ this must be the first line of the constructor


6. Question 6 – The two setAge methods

  • ❌ accessors

  • ✔️ overloading

  • ❌ overriding

  • ✔️ mutators


SUMMARY TABLE

Q.No Correct Option(s) Answer
1 ✔️ Option 4 Private vars protect object state (abstraction)
2 ✔️ Option 4 Mutator method
3 ✔️ Options 1 & 4 Correct Vehicle constructors
4 ✔️ Options 1 & 2 Default constructor removed; must recreate
5 ✔️ Option 4 this(...) must be first line
6 ✔️ Options 2 & 4 Overloading + mutators