Previous Section  < Day Day Up >  Next Section

Q&A

Q1:

Does a threaded animation program have to use Thread.sleep() to pause, or can you omit it to produce the fastest possible animation?

A1:

You have to put some kind of pause in place in an animation program, or the program will crash or behave erratically. Without pauses, Java won't be able to keep up with constant repaint() requests and may be unable to respond to mouse-clicks on its interface and other user input. Part of the process of animation design in Java is finding the right display speed that all environments can handle.

Q2:

What happens if you draw something, such as an image, to coordinates that aren't within the window?

A2:

Methods that draw something to a coordinate will continue to draw it even if none of it is visible within the area shown by the applet window or application frame. This is a good way to have something move into view, because the portion of the image that falls into the visible area will be displayed.

Q3:

After completing this book, will I be able to pass the programmer certification test?

A3:

Every programming language has features great for expert-level coders that send beginners fleeing in terror.

In Java, a good example is the ternary operator introduced in Hour 7, "Using Conditional Tests to Make Decisions," which uses a true-false boolean expression to produce one of two values. A Java programmer can avoid learning about the ternary operator entirely, because the same effect can be achieved with a simple if-else block statement.

Certification test writers love ternary operators and other obscure but powerful aspects of the language. For this reason, you'll need more prep before taking one of these tests.

Shameless plug ahead: Each chapter of Sams Teach Yourself Java 2 in 21 Days, Fourth Edition, the book I coauthored with Laura Lemay, ends with a certification practice question.

Q4:

Why is a man who dates a bunch of different women called a "lothario"?

A4:

Lothario is a character in The Fair Penitent, a play written in 1703 by Nicholas Rowe. In the play, Lothario seduces Calista, the daughter of a lord. This is discovered on the day of her wedding to Lord Altamont, which leads to a duel, street riot, and a really bad day for everyone involved.

The character was known as the "gay Lothario" for several centuries, taking an expression used in Rowe's play. He would be more accurately described today as the straight Lothario.

    Previous Section  < Day Day Up >  Next Section