Java Reference
In-Depth Information
A. Type-safe
B. Reusable
C. Reliable
D. All of the above
D. All of the above
2 . Can a primitive type be used as a type argument?
No, type arguments must be object types.
3 . Show how to declare a class called FlightSched that takes two generic parameters.
The solution is
4 . Beginning with your answer to question 3, change FlightSched 's second type para-
meter so that it must extend Thread .
The solution is
5 . Now, change FlightSched so that its second type parameter must be a subclass of its
first type parameter.
The solution is
6 . As it relates to generics, what is the ? and what does it do?
The ? is the wildcard argument. It matches any valid type.
7 . Can the wildcard argument be bounded?
Yes, a wildcard can have either an upper or lower bound.
8 . A generic method called MyGen( ) has one type parameter. Furthermore, MyGen( )
has one parameter whose type is that of the type parameter. It also returns an object
of that type parameter. Show how to declare MyGen( ) .
The solution is
9 . Given this generic interface
Search WWH ::




Custom Search