MCQ Chapter-1 Java Applets
MCQ Chapter-1 Java Applets
(1) Which method is called only once during the run time of applet?
a.stop()
b. init()
c. stat()
d. destroy()
(2) Which is a required attribute that gives the name of the file containing your applet’s compiled .class file?
a.codebase
b.codeclass
c. codename
d. code
(3) Which are the common security restrictions in applets?
a. Applets can't load libraries or define native methods.
b. An applet can't read every system property.
c. Applets can play sounds.
d. Both A & B
(4) From the following statements which is a drawback for Applet?
a. It works at client side so less response time
b. Most of the web browsers support applets.
c. It can be executed by browsers running under many platforms, including Linux, Windows, and Mac Os
etc.
d. Plugin is required at client browser to execute applet
(5) Applet works at client side so less response time.
a. True
b. False
c. May be
(6) The APPLET tag is used to start an applet from both an HTML document and from an applet viewer.
a. True
b. False
(7) What invokes immediately after the start() method and also any time the applet needs to repaint itself in the
browser?
a.stop()
b. init()
c. paint()
d. destroy()
(8) When an applet is terminated which of the following sequence of methods calls take place?
a. stop(),paint(),destroy()
b. destroy(),stop(),paint()
c. destroy(),stop()
d. stop(),destroy()
(9) Applet runs inside the browser and does not work at client side.
a. True
b. False
c. May be
(10) Which is a special type of program that is embedded in the webpage to generate the dynamic content?
a. Package
b. Applet
c. Browser
d. None of the above
(11) What is used to run an Applet?
a. An html file
b. An AppletViewer tool(for testing purpose)
c. Both A & B
d. None of the above
(12) Which is the correct order of lifecycle in an applet?
a. Applet is started, initialized, painted, destroyed, stopped
b. Applet is painted, started, stopped, initilaized, destroyed
c. Applet is initialized, started, painted, stopped, destroyed
d. None of the above
(13) Java Plug-in software is not responsible to manage the lifecycle of an Applet.
a. True
b. False
c. May be
(14) Which method is used to suspend threads that don’t need to run when the applet is not visible?
a. destroy()
b. paint()
c. stop()
d. start()
(15) All Applets must import java.applet and java.awt.
a. True
b. False
(16) Which of the following methods is provided by java.awt.component class?
a. public void paint(Graphics g)
b. public void destroy()
c. public void stop()
d. public void init()
(17) Which method is invoked when browser is maximized?
a. public void start()
b. public void paint(Graphics g)
c. Public void stop()
d. Public void init()
(18) Which of these functions is called to display the output of an applet?
a. display()
b. paint()
c.displayApplet()
d.PrintApplet()
(19) Which of these methods can be used to output a string in an applet?
a. display()
b. print()
c.drawString()
d. transient()
(20) What is the Message is displayed in the applet 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);
}
}
a Simple Applet
b. A Simple Applet 20 20
c. Compilation Error
d. Runtime Error
(21) What is the output of following Java program?
import java.awt.*;
import java.applet.*;
public class myapplet extends Applet
{
Graphic g;
g.drawString("A Simple Applet", 20, 20);
}
a Simple Applet
b. A Simple Applet 20 20
c. Compilation Error
d. Runtime Error
(22) Arrange the steps involved in developing and testing the applet in correct order.
i) creating an executable applet (.classfile)
ii) preparing <APPLET> tag
iii) creating HTML file
iv) building an applet code (.java file)
v) testing the applet code
a. True, False
b. False, True
c. True, True
d. False, False
(24) Applet class is a subclass of the panel class, which is again a subclass of the ………………….. class.
a. object
b. component
c. awt
d. container
(25) The ………………method is called every time the applet receives focus.
a. init( )
b. start( )
c. stop( )
d. destroy( )
(26) Which of the following applet tags is correct to embed an applet class named Test into a webpage?
(43) An applet can play an audio file represented by the AudioClip interface in the java,applet package Causes the
audio clip to replay continually in which method?
a. public void play()
b. public void loop()
c. public void stop()
d. None of the above
(44) Applets cannot make network connection exception to the server host from which it originated?
a. True
b. False
(45) AppletViewer tool is available in which of the folder of JDK?
a. bin
b. lib
c. source
d. class
(46) The Applet class is in ………..package
a. java.applet
b. java.awt
c. java.io
d. java.util
(47) To run an applet……….command is used.
a. run
b. java
c. appletviewer
d. applet
**************************