- 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
- 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
多个重载方法可以由方法的参数个数、类型及参数顺序来区分。 6-* Method Overloading Method overloading is the process of giving a single method name multiple definitions If a method is overloaded, the method name is not sufficient to determine which method is being called The signature of each overloaded method must be unique The signature includes the number, type, and order of the parameters 6-* Method Overloading The compiler determines which method is being invoked by analyzing the parameters float tryMe(int x) { return x + .375; } float tryMe(int x, float y) { return x*y; } result = tryMe(25, 4.32) Invocation 6-* Method Overloading The println method is overloaded: println (String s) println (int i) println (double d) and so on... The following lines invoke different versions of the println method: System.out.println (The total is:); System.out.println (total); 6-* Overloading Methods The return type of the method is not part of the signature That is, overloaded methods cannot differ only by their return type Constructors can be overloaded Overloaded constructors provide multiple ways to initialize a new object 选出下列与方法public void add(int a){}为合理的重载方法。 A. public int add(int a) B. public void add(long a) C. public void add(int a,int b) public void add(float a) CD 继承 选出下列关于继承的叙述中正确的选项 A 在java中允许多重继承 B 在java中一个类只能实现一个接口。 C Java的单一继承使代码更可靠。 D 在java中一个类不能同时继承一个类和实现一个接口。 C 下面是有关子类继承父类构造函数的描述,其中正确的是: A创建子类的对象时,先运行完子类自身的构造函数,然后调用父类的构造函数。 B子类通过使用super关键字,调用父类的构造函数。 C子类无条件地继承父类不含参数的构造函数。 D子类无法继承父类的构造函数。 B 用super应用调用父类构造方法的操作只能在子类中执行,并且必须是在第一行执行。 * * 10-A-17 * 10-A-19 * 10b-18 * 交通工具,我们知道飞机、轮船、汽车、火车都是交通工具,都可以把乘客从一个地方带到另外一个地方,但是各种不同的交通工具的运行方式是不同的,汽车沿着公路走,火车沿着铁路线走,飞机需要先起飞、飞行、然后降落,有一定的航线。正式因为有这些共同特征,才抽象出交通工具这样的类。 我们可以说具体的飞机、轮船、汽车和火车对象,但是没有交通工具对象,这时候交通工具就是抽象的。 * 构造函数 构造方法要与类名相同 无返回类型,也不需要void。 在类初始化的时候调用。 可重载 缺省构造方法 继承 关于Java中的接口和继承,下面说法正确的是: 在Java中允许继承多个类,在extends关键字之后分别列出。 在Java中一个类只能实现一个接口。 在Java中一个类不能同时继承一个类和实现一个接口。 如果接口A继承自另外一个接口B,那
文档评论(0)