Questions from Starting Out With Java


Q: Suppose the file MyApplet.java contains the Java source code for

Suppose the file MyApplet.java contains the Java source code for an applet. What tag would you write in an HTML document to run the applet in an area that is 400 pixels wide by 200 pixels high?

See Answer

Q: To create an applet using AWT, what class do you inherit

To create an applet using AWT, what class do you inherit your applet class from?

See Answer

Q: In Swing, if an object’s class extends JFrame or

In Swing, if an object’s class extends JFrame or JApplet, you add components to its content pane. How do you add components to an object if its class extends Frame or Applet?

See Answer

Q: In an AWT component, or a class that extends JApplet or

In an AWT component, or a class that extends JApplet or JFrame, if you want to get a reference to the Graphics object, do you override the paint or paintComponent method?

See Answer

Q: In a JPanel object, do you override the paint or paintComponent

In a JPanel object, do you override the paint or paintComponent method to get a reference to the Graphics object?

See Answer

Q: Why do applets run in a restricted environment?

Why do applets run in a restricted environment?

See Answer

Q: When are the paint and paintComponent method called?

When are the paint and paintComponent method called?

See Answer

Q: Look at the following interface: public interface Computable {

Look at the following interface: public interface Computable { double compute(double x); } Write a statement that uses a lambda expression to create an object that implements the Computable interface....

See Answer

Q: In the paint or paintComponent method, what should be done before

In the paint or paintComponent method, what should be done before anything else?

See Answer

Q: How do you force the paint or paintComponent method to be called

How do you force the paint or paintComponent method to be called?

See Answer