第7章接口和包1.ppt

  1. 1、本文档共73页,可阅读全部内容。
  2. 2、有哪些信誉好的足球投注网站(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
JAVA语言程序设计 第7章 抽象类和接口 附件1:包命名约定 Sun microsystems公司制度了一个包命名的约定,所有的java程序员都应遵循该约定。每个包的名称应以Internet域名的倒序开始。例如,如果Internet域名为,则包名应为com.deitel开始。如果域名为,包名开始应为edu.yourcollege。在倒序域名之后,你可以为包选择任何其他你所希望的名称。如果你在一家拥有很多部门的公司,或在某所拥有很多学院的大学中任教,可能希望将你所在的部门或学院的名称作为该包的下一个名称。我们选用jcsj1作为包的下一个名称,以表示该类来自于本书。我们包名的最后部分指定该包位于第7章(ch07)。通过查看import声明中包名的最后部分,读者可以确定我们的可重用类是在哪一章中声明的。这出现在引用的类名之前,如果没有指定某个特定的类,则在*之前。 例:package com.deitel.jcsj1.ch07 附件二:定位.class类文件 类加载器(class loader)。 类加载器首先查找与j2sdk捆绑在一起的标准java类。 然后查找可选包。Java2提供了一个可扩展机制,该机制使新的(可选的)包能够添加到Java中,以用于开发和执行目的。 如果在标准java类或在扩展类中没有找到所需的类,则类加载器查找classpath路径,该路径列出了类的存储位置。classpath路径由一列目录或存档文件组成,各个目录或文件之间由目录分割符分开——Windows的目录分隔符为分号(;)。 19.Given package foo; public class Outer { public static class Inner { } } which statement is true? A.An instance of the Inner class can be constructed with “new Outer.Inner()” B. An instance of the Inner class cannot be constructed outside of package foo C. An instance of the Inner class can only be constructed from within the Outer class. D. An instance of the Inner class can be constructed with “new Inner()” 20.which two demonstrate an “is a” relationship? A.public interface Person { } public class Employee extends Person { } B. public interface Shape { } public interface Retangle extends Shape { } C.public interface Color{ } public class Shape { private Color color;} D. public class Species{ } public class Animal { private Species species;} E. interface Component { } class Container implements Component { private Component[] children; } 21.The following list the complete contents of the file Test.java interface Foo { int k=0; } public class Test implements Foo { public static void main(String args[]) } int i; Test test=new Test(); i=test.k; i=Test.k; i=Foo.k; } } What will happen when this file is compiled? A.compilation succeeds. B.An error at line 2 causes compilation to fail. C. An error at line 9 causes compil

文档评论(0)

好文精选 + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

1亿VIP精品文档

相关文档