注册 登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

尝试将复杂的问题简单化-zzy

纸上得来终觉浅,绝知此事要躬行。

 
 
 

日志

 
 
关于我

教书是职业的要求,教学是份内的事,要努力做一个好教师.

网易考拉推荐

<OOP> Experiment 8 Java access specifiers  

2007-10-25 12:10:17|  分类: 默认分类 |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |

 8.1 The purpose of experiment

1.Learning the various types of access with the default access;

2.  Knowing how to use public, private, protected and default access in java.

8.2 The content of experiment

1. Change the class Cookie as specified in the section labeled “protected: inheritance access.” Verify that bite( ) is not public.

2. Create the following file in the c05/local directory (presumably in your CLASSPATH):

// c05:local:PackagedClass.java

package c05.local;

class PackagedClass {

  public PackagedClass() {

    System.out.println("Creating a packaged class");

  }

}

 Then create the following file in a directory other than c05:

// c05:foreign:Foreign.java

package c05.foreign;

import c05.local.*;

public class Foreign {

   public static void main (String[] args) {

      PackagedClass pc = new PackagedClass();

   }

}

3、  Write a method that creates and initializes a two-dimensional array of double. The size of the array is determined by the arguments of the method, and the initialization values are a range determined by beginning and ending values that are also arguments of the method. Create a second method that will print the array generated by the first method. In main( ) test the methods by creating and printing several different sizes of arrays..

8.3 Experiment programming & Experiment result

 

8.4 Please explain : Why the compiler generates an error. Would making the Foreign class part of the c05.local package change anything?

 

  评论这张
 
阅读(447)| 评论(0)
推荐 转载

历史上的今天

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2017