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);
}
}
import java.awt.*;
import java.applet.*;
public class myapplet extends Applet
{
public void paint(Graphics g)
{
g.drawString("A Simple Applet", 20, 20);
}
}
A. 20
B. 50
C. 100
D. System dependent
Answer: Option D
Solution (By Examveda Team)
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.
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