JHTP自测题_第八章_深入理解类和对象

来源:互联网 发布:淘宝hd最新版本 编辑:程序博客网 时间:2024/05/22 15:51



Self-Review Exercise


8.1Fill in theblanks in each of the following statements:


a) A(n)static importon demand imports all staticmembers of a class.


b)Stringclassstaticmethodformatis similar to method System.out.printf, but returns a formatted Stringrather thandisplaying aStringin a command window.


c) If a method contains alocal variable with the same name as one of its class’s fields, the localvariableshadows the field in that method’s scope.


d) Thepublicmethods of aclass are also known as the class’spublic services or interfaces.


e) A(n)single-type-importdeclaration specifies one class to import.


f) If a class declaresconstructors, the compiler will not create a(n)no-argument constructor.


g) An object’stoStringmethod is called implicitly when an object appears in code where aStringis needed.


h)Getmethods arecommonly calledaccessor or query method.


i) A(n)predicate methodtests whether a condition is true or false.


j) For everyenum, thecompiler generates astaticmethod calledvalues that returns an array of the enum’s constantsin the order in which they were declared.


k) Composition issometimes referred to as a(n)has-a relationship.


l) A(n)enum declarationcontains a comma-separated list of constants.


m) A(n)static variablerepresents classwide information that’s shared by all the objects of the class.


n) A(n)single-type-importdeclaration imports one staticmember.


o) Theprinciple of leastprivilege states that code should be granted only the amount of privilegeand access that it needs to accomplish its designated task.


p) Keywordfinal specifiesthat a variable is not modifiable after initialization in a declaration orconstructor.


q) A(n)type-import-on-demanddeclaration imports only the classes that the program uses from a particular package.


r)Setmethods arecommonly calledmutator because they typically change a value.


s) Use BigDecimal classto perform precise monetary calculations.


t) Use thethrow statement to indicate that a problem hasoccurred.



0 0
原创粉丝点击