Jodi is new to Java generics. She has proposed the following method. Will it work? If not, what has to be changed to make it work?
```
1 // method to compute total perimeter of a collection of Shapes
2 public double totalPerimeter( Collection> c ) {
3 double total = 0.0;
4
5 for( Shape s : c )
6 total = total + s.getPerimeter();
7 return total;
8 }
```
Not quite. One line 2, the parameter to the method is of type Collection>, which would allow the passing of objects other than Shapes. The compiler is going to use the default upper bound for ‘?’, which is Object, and consequently will complain about the use of s and c in the for loop header “Shape s : c”. This is easily solved by changing the header to Collection extends Shape> c , or better still, Collection extends Shape> c
You might also like to view...
For a class template, the scope resolution operator (::) is needed:
a. Only in the definitions of the member functions defined outside the class. b. Both in the prototype and definition of a member function. c. Only if multiple class-template specializations will be created from this class template. d. In neither the definition nor prototype of member functions.
Identify the letter of the choice that best matches the phrase or definition.
A. A design consideration for this type of page element is "Do they all include alternate text?" B. A design consideration for this type of page element is "Do they include summaries or headings?" C. A design consideration for this type of page element is "Has the embedded code been provided that searches for the appropriate plug-ins and prompts missing plug-ins to download?" D. A design consideration for this type of page element is "Are the font sizes large enough for users to read?" E. A design consideration for this type of page element is "Will the site pass the W3C Priority 1 Checkpoints?"
Which of the following is an example of a biometric authentication?
A. Token B. PIN C. Smart card D. Signature dynamics
What are the three physical components of a VSAM file?
What will be an ideal response?