Quiz Answers

Answers

1. Given two objects one and two of BigDecimal type, how do you multiply the two factors to calculate a product in object three? Answer: D
To generate the product of two variables of BigDecimal type, use the multiply() method of BigDecimal. This was shown in "The Need for BigDecimal" (July 2007), which also discussed formatting and rounding issues.

2. In order to write the line System.out.println("Pi = " + PI), what must the import statement be so that the compiler will locate PI in the Math class? Answer: C
Use static import statements to tell the compiler about constants and methods you wish to use without explicitly specifying the class they come from. See "Using Static Imports for Constants and Methods" (October 2004) for more information on working with static imports.

3. When using an enhanced for loop (also known as a foreach statement), what interface must the element following the colon (:) implement in order for the construct to compile and execute appropriately? Answer: B
The argument must implement the Iterable interface, which consists of a single method, to get an iterator:

Iterator iterator()

"The Enhanced For Loop" (May 2005) started the discussion of using the enhanced for loop. The use of Iterable was discussed later in "Using Enhanced For-Loops With Your Classes" (September 2007).

4. When two Swing components overlap in their display area, how do you control which component is drawn on top? Answer: C
Z-order represents the layering of the components on the screen, where x and y coordinates are for horizontal and vertical positioning, respectively. By calling the setComponentZOrder() method of the Container for each component that overlaps, you can explicitly control which components are drawn on top of which other components. See "Let There Be Z-Order" tip (January 2005) for additional information on controlling the z-order layering.

5. What is the best way to monitor the progress of image reading when using the Java Image I/O API? Answer: C
Although you can certainly display progress with a Progress Monitor, the best way to set up notification of such progress is by using a IIOReadProgressListener. "Monitoring Image I/O Events" (February 2007) covered this notification as well as region-update notifications.

Comments:

Can i get the quiz for method and its answer ?

Posted by guest on February 11, 2008 at 08:09 PM PST #

Post a Comment:
Comments are closed for this entry.
About

John O'Conner

Search

Categories
Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today