——JAVA
JAVA语言中的抽象类和接口(2
一、练习目标:
1. 内部类和接口的使用。
二、练习时间与作业要求:
本次练习一共需要180分钟。翻译练习写在JAVA笔记本上,书面作业写在JAVA家庭作业本上。
后面的书面作业不包括在这个时间范围内。
三、翻译练习:
将下面要求翻译的内容,写在记事本上(阴影部分不写出来,要求看懂)
java网课推荐Why upcasting?
The reason for the term is historical, and based on the way class inheritance diagrams have traditionally been drawn: with the root at the top of the page, growing downward. (Of course, you can draw your diagrams any way you find helpful.) The inheritance diagram for Wind.java is then:
Casting from a derived type to a base type moves up on the inheritance diagram, so it’s commonly referred to as upcasting. Upcasting is always safe because you’re going from a more specific type to a more general type. That is, the derived class is a superset of the base class. It might contain more methods than the base class, but it must contain at leas
t the methods in the base class. The only thing that can occur to the class interface during the upcast is that it can lose methods, not gain them. This is why the compiler allows upcasting without any explicit casts or other special notation.
java.lang
Class String
Class String java.lang.Object
  +--java.lang.String
All Implemented Interfaces: CharSequence, Comparable, Serializable
The class String includes methods for examining individual characters of the sequence, for comparing strings, for searching strings, for extracting substrings, and for creating a copy of a string with all characters translated to uppercase or to lowercase. Case mapping relies heavily on the information provided by the Unicode Consortium's Unicode 3.0 specification. The specification' files are used
extensively to provide case mapping. The Java language provides special support for the string concatenation operator ( + ), and for conversion of other objects to strings. String concatenation is implemented through the StringBuffer class and its append method. String conversions are implemented through the method toString, defined by Object and inherited by all classes in Java. For additional information on string concatenation and conversion, see Gosling, Joy, and Steele, The Java Language Specification.
四、上机练习:
1. 定义飞这样的一个接口,使用超人、鸟 、飞机类实现该接口中飞方法。
2、编写一个说话的接口,人,狗,汽车类去实现接口中的方法。

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。