Tips for using core Java SE APIs
Core Java Technologies Tech Tips
Archives
« October 2009
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
31
       
Today
Click me to subscribeSubscribe
Search

Links
 

Today's Page Hits: 967

« Placing Components... | Main | Quiz Answers »
Tuesday Jan 08, 2008
January 2008 Core Java Tech Tips Quiz
by John Zukowski

We've made it through another year, and it's time for another tech tips quiz. The last two -- June 2006 and September 2005 -- were popular refreshers of past tips and tricks. Here are another five questions for you. Don't look too far ahead, as the answers are at the end of this entry.

1. Given two objects one and two of BigDecimal type, how do you multiply the two factors to calculate a product in object three?

a. BigDecimal three = one * two;
b. BigDecimal three = one.*(two);
c. BigDecimal three = one.times(two);
d. BigDecimal three = one.multiply(two);

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?

a. import java.lang.Math;
b. import java.lang.Math.PI;
c. import static java.lang.Math.PI;
d. import final java.lang.Math.PI;

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?

a. Enumeration
b. Iterable
c. Iterator
d. Collection

4. When two Swing components overlap in their display area, how do you control which component is drawn on top?

a. The component added to the container first is drawn on top.
b. The component added to the container last is drawn on top.
c. You call the setComponentZOrder() method of the container.
d. You call the setComponentZOrder() method for each component.

5. What is the best way to monitor the progress of image reading when using the Java Image I/O API?

a. Create a FilteredReader subclass to count the bytes.
b. Attach a ProgressMonitorListener to the ImageReader to report progress.
c. Attach an IIOReadProgressListener to the ImageReader for progress reporting.
d. Register a Runnable with the ImageReader and tell it how frequently to execute.

Check your answers here.


Comments:

good

Posted by 61.17.102.124 on January 23, 2008 at 06:11 AM PST #

good

Posted by Channa Vimukthi on February 07, 2008 at 03:23 AM PST #

good

Posted by 59.96.101.159 on February 18, 2008 at 10:52 PM PST #

very good quiz

Posted by coredev on February 19, 2008 at 08:33 PM PST #

Post a Comment:
Comments are closed for this entry.