Which of the following methods is a static method? The class in which the method is defined is given in parentheses following the method name.

Which of the following methods is a static method?  The class in which the method is defined is given in parentheses following the method name.

a)       equals (String)
b)       toUpperCase (String)
c)       sqrt (Math)
d)       format (DecimalFormat)
e)       paint (Applet)
Answer:  c.

Explanation:  The Math class defines all of its methods to be static.  Invoking Math methods is done by using Math rather than a variable of type Math.  The other methods above are not static.


Enhancing Classes

Learn More Multiple Choice Question :