Java Reference
In-Depth Information
Boxing is the process of storing a primitive value in a type wrapper object. Unboxing
is the process of retrieving the primitive value from the type wrapper. Autoboxing
automatically boxes a primitive value without having to explicitly construct an ob-
ject. Auto-unboxing automatically retrieves the primitive value from a type wrapper
without having to explicitly call a method, such as intValue( ) .
6 . Change the following fragment so that it uses autoboxing.
The solution is
7 . In your own words, what does static import do?
Static import brings into the global namespace the static members of a class or inter-
face. This means that static members can be used without having to be qualified by
their class or interface name.
8 . What does this statement do?
The statement brings into the global namespace the parseInt( ) method of the type
wrapper Integer .
9 . Is static import designed for special-case situations, or is it good practice to bring all
static members of all classes into view?
Static import is designed for special cases. Bringing many static members into view
will lead to namespace collisions and destructure your code.
10 . An annotation is syntactically based on a/an ________________.
interface
11 . What is a marker annotation?
A marker annotation is one that does not take arguments.
12 . An annotation can be applied only to methods. True or False?
False. Any type of declaration can have an annotation. Beginning with JDK 8, a type
use can also have an annotation.
Chapter 13: Generics
1 . Generics are important to Java because they enable the creation of code that is
Search WWH ::




Custom Search