Java MCQ Questions - Java Applets
This section focuses on the "Java Applets" in Java programming. These Multiple Choice Questions (MCQ) should be practiced to improve the Java programming skills required for various interviews (campus interview, walk-in interview, company interview), placements, entrance exams and other competitive examinations.
1. An applet is a Java class that extends the?
A. java.Applet class
B. java class
C. Applet class
D. java.applet.Applet class
View Answer
Ans : D
Explanation: An applet is a Java class that extends the java.applet.Applet class
2. Applets are designed to be embedded within an __________.
A. Javascript
B. Css
C. HTML
D. SQL
View Answer
Ans : C
Explanation: Applets are designed to be embedded within an HTML page.
3. Which of the following is required to view an applet?
A. JCM
B. JDM
C. JVM
D. Java class
View Answer
Ans : C
Explanation: A JVM is required to view an applet. The JVM can be either a plug-in of the Web browser or a separate runtime environment.
4. Which method is automatically called after the browser calls the init method?
A. start
B. stop
C. destroy
D. paint
View Answer
Ans : A
Explanation: start : This method is automatically called after the browser calls the init method. It is also called whenever the user returns to the page containing the applet after having gone off to other pages.
5. Which method is only called when the browser shuts down normally?
A. start
B. stop
C. destroy
D. paint
View Answer
Ans : C
Explanation: destroy : This method is only called when the browser shuts down normally. Because applets are meant to live on an HTML page, you should not normally leave resources behind after a user leaves the page that contains the applet.
6. Which of these operators can be used to get run time information about an object?
A. getInfo
B. Info
C. instanceof
D. getinfoof
View Answer
Ans : C
Explanation: instanceof can be used to get run time information about an object
7. Which method causes the audio clip to replay continually?
A. public void play()
B. public void loop()
C. public void stop()
D. None of the above
View Answer
Ans : B
Explanation: public void loop() : Causes the audio clip to replay continually
8. paint() is an abstract method defined in AWT.
A. TRUE
B. FALSE
C. Can be true or false
D. Can not say
View Answer
Ans : A
Explanation: paint() is an abstract method defined in AWT.
9. ___________ method is defined in Graphics class, it is used to output a string in an applet.
A. display()
B. Print()
C. drawString()
D. transient()
View Answer
Ans : C
Explanation: drawString() method is defined in Graphics class, it is used to output a string in an applet.
10. What will be output for the following code?
import java.awt.*;
import java.applet.*;
public class myapplet extends Applet
{
public void paint(Graphics g)
{
g.drawString(""A Simple Applet"", 20, 20);
}
}
A. A Simple Applet
B. A Simple Applet 20 20
C. Compilation Error
D. Runtime Error
View Answer
Ans : A
Explanation: A Simple Applet be output for the following code.
Discussion