ExamVeda
Login
Home
This question belongs to Java Program Input Output
Input Output
?

What is the length of the application box made by the following Java program?
import java.awt.*;
import java.applet.*;
public class myapplet extends Applet
{
    public void paint(Graphics g)
    {
        g.drawString("A Simple Applet", 20, 20);    
    }
}

Answer & Solution
Correct Answer: Option D
The Java program provided uses the AWT and Applet classes to draw a string on the screen using the paint() method.

However, it does not explicitly specify the size (length or width) of the application box (applet window).

When an applet does not set its size using methods like setSize(), the actual size of the applet is determined by the HTML page that embeds the applet or by the applet viewer or browser displaying it.

Because different systems and viewers may allocate different default sizes, the length of the application box is therefore system dependent.
Examveda
Question posted by Examveda
Community

Join the Discussion

1 Comment
Ganesh Commn
Ganesh Commn 1 year ago
Applets don't have an intrinsic size - they must be sized by their container

The coordinates in drawString() (20,20) position the text within the applet, but don't affect the applet's dimensions

Without explicit sizing, the applet will use whatever default size the environment provides