Java面向对象【经典案例】参数:尽可能简单的转换

来源:互联网 发布:ipad上传淘宝宝贝软件 编辑:程序博客网 时间:2024/05/17 09:30
package day02;/** *  参数: 尽可能简单的转换(就近原则) */public class Demo08 {public static void main(String[] args) {Goo g = new Goo('A');//请选择输出结果: //A.编译错 B.运行异常 C.Goo(long) D.Goo(int)}}class Goo{public Goo() {System.out.println("Goo()");}//public Goo(){}//编译错误, 重复定义构造器//public Goo(int b){}//编译错误, 重复定义构造器public Goo(int a){System.out.println("Goo(int)");}public Goo(long a){System.out.println("Goo(long)");}}运行结果:Goo(int)


原创粉丝点击