解释一下这道java选择题

来源:百度知道 编辑:UC知道 时间:2024/05/25 12:41:01
9. The method sqrt(double num)in the class java.lang.Math is
A. An instance method of the class Math
B. A constructor of the class Math
C. A private method of the class Math
D. A static method of the class Math

答案是D

答案应该没错,调用sqrt()方法无需实例化Math这个类
既不需要Math math=new Math(); math.sqrt();
而直接通过类名.方法名即可
原因是静态的方法在编译阶段就开辟了空间并实例化。
所以你就不需要再new拉

是啊, sqrt(double num)是Math的静态方法,用的时候可以不用NEW,直接
Math.sqrt(double num)就行

这个,你查一下JDK文档,应该就明白了。
学JAVA不看JDK不行。

英语确实很重要。。哈哈 还好看得懂

D
是一个静态方法,可以直接调用,也可以实例化后调用