What is the length of the application box made in the following Java program? [code] import java.awt.*; import java.applet.*;

What is the length of the application box made in the following Java program?
Code:
    import java.awt.*;
    import java.applet.*;
    public class myapplet extends Applet 
    {
        Graphic g;
        g.drawString("A Simple Applet",20,20);    
    }
A. 20
B. Default value
C. Compilation Error
D. Runtime Error
 
Answer: c
Explanation: To implement the method drawString we need first need to define abstract method of AWT that is paint() method. Without paint() method we cannot define and use drawString or any Graphic class methods.
 

Tìm kiếm

Back
Top