I am trying to print out the area of a rectangle using the following code
System.out.println("Area of rectOne: " + rectOne.getArea());
however since the method getArea is defined in another class shouldn’t it be
System.out.println("Area of rectOne: " + rectOne.NameOfClass.getArea());
This answer assumes
rectOneis reference to instance of the class which hasgetArea()method.getArea()is instance method, so, you need reference to instance of this class to accessgetArea()method.