Question 1
Q1A financial application calculates compound interest. During a code review, the following line is flagged: double total = principal * Math.pow(1 + rate, time);. The variables principal, rate, and time are all of type double. Which statement accurately describes the use of the Math class in this context?
Show answer & explanation
Correct answer: B
The Math class in the java.lang package consists of static methods and constants. Static members belong to the class itself, not to any specific instance. Therefore, they are called using the class name, like Math.pow(), without needing to create an object (e.g., new Math()). In fact, the Math class has a private constructor, so it cannot be instantiated.