Multiple choice technology

Given: 1. package geometry; 2. public class Hypotenuse { 3. public InnerTriangle it = new InnerTriangle(); 4. class InnerTriangle { 5. public int base; 6. public int height; 7. } Which statement is true about the class of an object that can reference the variable base?

  1. It can be any class

  2. No class has access to base

  3. The class must belong to the geometry package

  4. The class must be a subclass of the class Hypotenuse

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

InnerTriangle is a package-private class (no access modifier before 'class'), meaning only classes within the geometry package can access it. Since base is a public field inside InnerTriangle, any class that can access InnerTriangle can also access base. Therefore, only classes in the geometry package can reference the variable base.