当前位置: 技术问答>java相关
这两道题怎么解
来源: 互联网 发布时间:2015-02-09
本文导语: 看到两个题,不知何道理 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) { ...
看到两个题,不知何道理
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. }
答案是The code compiles cleanly and shows "String Version".
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. }
答案是The code does not compile.
请教各位高手为什么这样的结果呢?
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. }
答案是The code compiles cleanly and shows "String Version".
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. }
答案是The code does not compile.
请教各位高手为什么这样的结果呢?
|
http://www.csdn.net/expert/TopicView.asp?id=300131
本站(WWW.)旨在分享和传播互联网科技相关的资讯和技术,将尽最大努力为读者提供更好的信息聚合和浏览方式。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。