Home | Articles
JDC Programming Quiz
By Monica Pawlan
April 1998
Back to Quiz
- A thread is at a wait
statement and is notified by another thread that has the lock on that
object to proceed. Under what conditions can the thread at the wait
statement continue?
Answer (C): The thread can continue once the notify
thread has exited its synchronized block, and the wait thread has
obtained the lock on that object.
- What is required when writing a JavaBean?
Answer (D): None of the above.
You do not have to use strict naming conventions, but it is certainly advisable.
There is no getBeanType method, and the Beans
class contains only static methods.
- You are trying to change the
string on a label from "short string" to "some very long-winded,
verbose string," but the new label is always truncated. What you see is
something like "some very l...". How do you fix this?
Answer (A): Invalidate the object whose label you are changing
and force its parent container to validate itself.
aLabel.setText("some very long-winded, verbose string");
aLabel.invalidate();
parent_container_of_aLabel.validate():
- Which of the following statements is true about JDK 1.1?
Answer (B): The event model is different from JDK 1.0.
- You are writing JDK 1.1 code
that can be called by JDK 1.0 and you need to override a deprecated
method. How can you be sure your code will work?
Answer (C): Override the deprecated method to call
the replacement method, and override the replacement method to
implement the required functionality.
- A Java program can set up
its own configurable program attributes to specify things like startup
parameters and preferred window size. What are the mechanisms for Java
programs to set their own set of program attributes?
Answer (D): Properties, command-line arguments, and applet
parameters.
- Knowing the height and width
of an image can be helpful when creating web pages or designing user
interfaces. What class provides a way to get information on an image
including its height and width?
Answer (B):
java.awt.image.ImageConsumer
- Which one of the following
will not pick up the pressed JRadioButton? All of the examples use the
following object: RadioButton myButton = new JRadioButton();
Answer (D): All options are correct except D. There is
no getButtonModel() method.
ButtonModel mymodel=myButton.getButtonModel();
mymodel.addActionListener(myListener);
myButton.setModel(mymodel);
class RadioListener implements ActionListener {
public void actionPerformed(ActionEvent e) { }
}
- Which of the following is not a Bean property?
Answer (B): Action.
An Action is not a Bean property.
- What is a Beans Event Adapter?
Answer (D): An object that interposes between event
sources and event listeners to provide added control over event delivery.
You missed 0
Your score is 100 percent.
© 1994-2005 Sun Microsystems, Inc.