R4R
Right Place For Right Person TM
 
R4R Java Faqs

Java Interview Questions With Answers


Applets

Question 1) What is an Applet? Should applets have constructors?

Ans : Applet is a dynamic and interactive program that runs inside a Web page displayed by a Java capable browser. We don’t have the concept of Constructors in Applets.

Question2) How do we read number information from my applet’s parameters, given that Applet’s getParameter() method returns a string?

Ans : Use the parseInt() method in the Integer Class, the Float(String) constructor in the Class Float, or the Double(String) constructor in the class Double.

Question3) How can I arrange for different applets on a web page to communicate with each other?
Ans : Name your applets inside the Applet tag and invoke AppletContext’s getApplet() method in your applet code to obtain references to the other applets on the page.

Question 4) How do I select a URL from my Applet and send the browser to that page?

Ans : Ask the applet for its applet context and invoke showDocument() on that context object.

Eg. URL targetURL;

String URLString

AppletContext context = getAppletContext();

try{

targetUR L = new URL(URLString);

} catch (Malformed URLException e){

// Code for recover from the exception

}

context. showDocument (targetURL);

Question 5) Can applets on different pages communicate with each other?

Ans : No. Not Directly. The applets will exchange the information at one meeting place

either on the local file system or at remote system.

Question 6) How do Applets differ from Applications?

Ans : Appln: Stand Alone

Applet: Needs no explicit installation on local m/c.

Appln: Execution starts with main() method.

Applet: Execution starts with init() method.

Appln: May or may not be a GUI

Applet: Must run within a GUI (Using AWT)

Question 7) How do I determine the width and height of my application?

Ans : Use the getSize() method, which the Applet class inherits from the Component

class in the Java.awt package. The getSize() method returns the size of the applet as

a Dimension object, from which you extract separate width, height fields.

Eg. Dimension dim = getSize ();

int appletwidth = dim.width ();

Question 8) What is AppletStub Interface?

Ans : The applet stub interface provides the means by which an applet and the browser communicate. Your code will not typically implement this interface.

Question 9) It is essential to have both the .java file and the .shtmll file of an applet in the same directory.

True.
False.
Ans : 2.

Question 10) The <PARAM> tag contains two attributes namely _________ and _______.

Ans : Name , value.

Question 11) Passing values to parameters is done in the _________ file of an applet.

Ans : .shtml.

Question 12) What tags are mandatory when creating HTML to display an applet

1. name, height, width
2. code, name
3. codebase, height, width
4. code, height, width
Ans : 4.

Question 13) Applet’s getParameter( ) method can be used to get parameter values.

a. True.
b.False.
Ans : a.

Question 14) What are the Applet’s Life Cycle methods? Explain them?

Ans : init( ) method - Can be called when an applet is first loaded.


start( ) method - Can be called each time an applet is started.

paint( ) method - Can be called when the applet is minimized or refreshed.

stop( ) method - Can be called when the browser moves off the applet’s page.

destroy( ) method - Can be called when the browser is finished with the applet.

Question 15) What are the Applet’s information methods?

Ans : getAppletInfo( ) method : Returns a string describing the applet, its author ,copy

right information, etc.

getParameterInfo( ) method : Returns an array of string describing the applet’s parameters.

Question 16) All Applets are subclasses of Applet.

a. True.
b. False.
Ans : a.

Question 17) All Applets must import java.applet and java.awt.

a. True.
b. False.
Ans : a.

Question 18) What are the steps involved in Applet development?

Ans : a) Edit a Java source file,

b) Compile your program and

c) Execute the appletviewer, specifying the name of your applet’s source file.

Question 19) Applets are executed by the console based Java run-time interpreter.

a. True.
b.False.
Ans : b.

Question 20) Which classes and interfaces does Applet class consist?

Ans : Applet class consists of a single class, the Applet class and three interfaces: AppletContext,

AppletStub and AudioClip.

Question 21) What is the sequence for calling the methods by AWT for applets?

Ans : When an applet begins, the AWT calls the following methods, in this sequence.

init( )
start( )
paint( )
Question 22) When an applet is terminated, the following sequence of method cals takes place :

stop( )
destroy( )

Question 23) Which method is used to output a string to an applet?

Ans : drawString ( ) method.

Question 24) Every color is created from an RGB value.

a. True.
b. False
Ans : a.

 

<<<Previous                                                                                                                    Next>>>
500 Java Objective Questions and Answer

New Updates

R4R
R4R
R4R
R4R
R4R
R4R
R4R
R4R