java 课程实践指导书
文件编号: YM/WI-19
文件版本: A 版
文件页码: page of
—— JAVA篇
JAVA 语言中的类( 2)
一、练习目标 :
1. 类的声明以及属性,方法的定义。
2. 类,属性,方法的访问权限。
3. final 的使用。
4. this 的使用。
5. Static 的使用。
二、练习时间与作业要求:
本次练习一共需要 180 分钟。翻译练习写在 JAVA笔记本上,书面作业写在 JAVA
家庭作业本上。
后面的书面作业不包括在这个时间范围内。
三、翻译练习:
将下面要求翻译的内容,写在记事本上
Class access
In Java, the access specifiers can also be used to determine which classes
within
a library will be available to the users of that library. If you want a class
to be available to a client programmer, you use the public keyword on the entire
class definition. This controls whether the client programmer can even create
an object of the class.
To control the access of a class, the specifier must appear before the keyword
class . Thus you can say:
public class Widget {
Now if the name of your library is mylib , any client programmer can access Widget
by saying
import mylib.Widget;
or
import mylib.*;
However, there ’s an extra set of constraints:
1. There can be only one public class per compilation unit (file). The idea
is that each compilation unit has a single public interface represented
by that public class. It can have as many supporting package-access
评论0
最新资源