CLASS VIII CHAPTER NAME : WORKING WITH APPLETS

Multiple Choice Questions

1     1. Which method is used to stop an applet ?
a.            init()                                   b.          start()  
c.            destroy()                            d.           stop()
2     2. Which method is used to draw anything on he display area of  an applet ?
a.            init()                                  b.           paint()
c.            start()                                d.           drawString()
3     3. Which method is called when an applet is loaded in the computer's memory for the first time ?                               a.            init()                                   b.          start()  
           c.            stop()                                 d.           destroy()
4     4. Which tag is used to specify an applet class ?
a.                  <BODY>                            b.          <TITLE>
c.           <APPLET>                        d.          <HEAD>                     
5     5. Which extension is used to save an html file ?
a.           .java                                   b.           .html
c.          .class                                  d.            .txt


True or False :-

11.  Applet run on a Java enabled Web browser.        TRUE
22.  Applets do not make a Web page interactive.     FALSE
33.  The Graphics class belongs to the standard Applet class.  FALSE
44.  paint() is a standard method of the Applet class.    TRUE
55.  The stop() method is called when a user moves to another Web page.  FALSE

Subjective Qustions :-

Qus. - 01 : Explain the life cycle  of an applet.
Ans:- 
The life cycle of an applet consists of four methods : init( ), start( ), stop( ) and destroy( )

init( ) :- This method is used to initialize an applet. It is called when an applet is loaded in the computer memory for the first time. It is called only once.

start( ) :- This method is automatically called after the init( ) method is invoked. It is also called whenever user restarts a process on the applet page. With the start( ) method the applet comes in the running state. In this state the paint( ) method is called.

stop( ) :- This method is used to stop an applet. It is called every time an applet is stopped or the browser is minimized.

destroy( ) :- This method is used to destroy an applet. It is called when an user moves to another web page.


Qus. - 02 : Explain the different HTML tags.
Ans :- 
HTML page have some basic tags which are as follows :
1. <HTML> :- It is a mother tag of html web page.
2. <TITLE> :- It is used to specify the document title.
3. <BODY> :- It consists of the content of the HTML document.
4. <APPLET> :- It is used to specify the applet class.


Qus. - 03 : What is AWT ?
Ans. :- AWT stands for Abstract Window Toolkit. It is a standard Java toolkit that provide classes and methods to create Graphical User Interface.


Qus. - 04 : Why is it important to inherit the standard Applet and Graphics classes ?
Ans. :- To create an applet program in Java, it is important and necessary to inherit the standard Applet and Graphics classes.


Qus. - 05 : What is the use of the paint() and drawString() methods ?
Ans. :- 
paint( ) :- This method is used to draw anything on the display area of an applet.
drawString() :- This method is used to display strings on an applet's display area.


Lab Question :

Qus. - 01 : Write a program to display name and age of a student using applets.
Ans:- 
         JAVA FILE :-
import java.applet.Applet;
import java.awt.Graphics;
public class Display extends Applet
{
public void paint(Graphics g)
{
g.drawString("Student Name : Amit Kumar",20,20);
g.drawString("Roll Number : 001",20,30);
}
}
HTML FILE :-
<html>
<title>Studnet Details</title>
<body>
<applet code="Display.class" width=200 height=300>
</applet>
</body>
</html>

Qus. - 02 : Write a program to  display marks of a student using applets.
Ans :-
JAVA FILE :-
import java.applet.Applet;
import java.awt.Graphics;
public class Marks extends Applet
{
public void paint(Graphics g)
{
g.drawString("Student Marks=60.00",20,20);
}
}
HTML FILE :-
<html>
<title>Studnet Details</title>
<body>
<applet code="Marks.class" width=200 height=300>
</applet>
</body>
</html>


Qus. - 03 : Write a program to display the average of five subjects and total marks using applets.
Ans. :- 

0 comments:

Post a Comment