知道为什么吗?

xiaming xiaming 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
Q78
What is the result of attempting to compile and run the following program

1. public class Test {

2. public void method(Object o) {
3. System.out.println("Object Version");
4. }

5. public void method(String s) {
6. System.out.println("String Version");
7. }

8. public static void main(String args[]) {
9. Test test = new Test();
10. test.method(null);
11. }
12. }

Select one correct answer
a. The code does not compile.
b. The code compiles cleanly and shows "Object Version".
c. The code compiles cleanly and shows "String Version".
d. The code throws an Exception at Runtime.
Answer:c


Q79
What is the result of attempting to compile the following program

1. public class Test {

2. public void method(StringBuffer sb) {
3. System.out.println("StringBuffer Verion");
4. }

5. public void method(String s) {
6. System.out.println("String Version");
7. }

8. public static void main(String args[]) {
9. Test test = new Test();
10. test.method(null);
11. }
12. }

Select one correct answer
a. The code does not compile.
b. The code compiles correctly and shows "StringBuffer Version".
c. The code compiles correctly and shows "String Version".
d. The code throws an Exception at Runtime
Answer:a.

请详细解释:
...全文
评论 11
收藏 已收藏
分享
返回顶部
xiaming
Java SE 62,621 成员 307,251 内容