YouTube Icon

Interview Questions.

Top 100+ Java Applet Interview Questions And Answers - May 31, 2020

fluid

Top 100+ Java Applet Interview Questions And Answers

Question 1. What Is An Applet? Should Applets Have Constructors?

Answer :

Applets are small programs transferred via Internet, automatically mounted and run as part of net-browser. Applets implements capability of a customer. Applet is a dynamic and interactive software that runs inner a Web page displayed by way of a Java-capable browser. We don’t have the concept of Constructors in Applets. Applets can be invoked both thru browser or through Appletviewer application provided by way of JDK.

Question 2. How To Insert Your Applets Into Frontpage?

Answer :

1. Place the .Elegance report in the directory containing the HTML report into that you need to insert the applet.
2. Copy the <applet>...</applet> tag out of your applet implementation or examples to the clipboard.
3. In FrontPage select the "HTML" tab from the lower left hand corner.
4. Paste the <applet>...</applet> tag in the proper location between the <body> and </body> tags. You'll discover a grey box with the aqua letter "J" within the "Normal" view indicating the the applet tag has been inserted.
Five. To see the applet appearance pick out the "Preview" tab.

 

Adv Java Interview Questions
Question three. What Is The Order Of Method Invocation In An Applet?

Answer :

? public void init() : Initialization method called as soon as through browser.
? public void begin() : Method known as after init() and carries code to begin processing. If the consumer leaves the web page and returns with out killing the modern browser session, the begin () approach is called without being preceded by using init ().
? public void prevent() : Stops all processing started via start (). Done if user actions off page.
? public void wreck() : Called if contemporary browser consultation is being terminated. Frees all resources used by applet.

Question 4. What Are The Applets Life Cycle Methods? Explain Them?

Answer :

strategies inside the life cycle of an Applet:
? init() approach - referred to as when an applet is first loaded. This technique is referred to as simplest as soon as in the entire cycle of an applet. This method usually intialize the variables to be used in the applet.
? begin( ) technique - referred to as every time an applet is started out.
? paint() approach - called whilst the applet is minimized or refreshed. This approach is used for drawing one-of-a-kind strings, figures, and images on the applet window.
? forestall( ) approach - known as when the browser actions off the applet’s web page.
? damage( ) approach - known as when the browser is finished with the applet.

Adv Java Tutorial
Question 5. What Is The Sequence For Calling The Methods By Awt For Applets?

Answer :

When an applet begins, the AWT calls the following strategies, in this series:
? init()
? begin()
? paint()

J2EE Interview Questions
Question 6. When An Applet Is Terminated, The Following Sequence Of Method Calls Takes Place:

Answer :

? forestall()
? destroy()

Question 7. How Do Applets Differ From Applications?

Answer :

Following are the primary variations: 
Application: Stand Alone, doesn’t want web-browser.
Applet: Needs no explicit installation on nearby gadget. Can be transferred through Internet on to the local device and might run as part of internet-browser.
Application: Execution starts offevolved with predominant() method. Doesn’t work if foremost isn't there.
Applet: Execution begins with init() method.
Application: May or may not be a GUI.
Applet: Must run within a GUI (Using AWT). This is essential feature of applets.

J2EE Tutorial Core Java Interview Questions
Question 8. Can We Pass Parameters To An Applet From Html Page To An Applet? How?

Answer :

We can bypass parameters to an applet using <param> tag inside the following way:
? <param name=”param1″ value=”value1″>
? <param name=”param2″ value=”value2″>
Access the ones parameters inside the applet is done via calling getParameter() technique inside the applet. Note that getParameter() technique returns String cost similar to the parameter call.

Question nine. How Do We Read Number Information From My Applets Parameters, Given That Applets Getparameter() Method Returns A String?

Answer :

Use the parseInt() approach inside the Integer Class, the Float(String) constructor or parseFloat() method in the Class Float, or the
Double(String) constructor or parseDoulbl() method inside the elegance Double.

JSP Interview Questions
Question 10. How Can I Arrange For Different Applets On A Web Page To Communicate With Each Other?

Answer :

Name your applets inside the Applet tag and invoke AppletContext’s getApplet() approach in your applet code to gain references to the other applets at the page.

Core Java Tutorial
Question eleven. How Do I Select A Url From My Applet And Send The Browser To That Page?

Answer :

Ask the applet for its applet context and invoke showDocument() on that context object.
URL targetURL;
String URLString
AppletContext context = getAppletContext();
attempt

targetURL = new URL(URLString);

trap (MalformedURLException e)

// Code for get over the exception

context. ShowDocument (targetURL);

Java-Springs Interview Questions
Question 12. Can Applets On Different Pages Communicate With Each Other?

Answer :

Use the getSize() technique, which the Applet elegance inherits from the Component magnificence within the Java.Awt bundle. The getSize() method returns the size of the applet as a Dimension object, from which you extract separate width, peak fields.
The following code snippet explains this:
Dimension dim = getSize();
int appletwidth = dim.Width();
int appletheight = dim.Height();

Adv Java Interview Questions
Question 13. Which Classes And Interfaces Does Applet Class Consist?

Answer :

Applet elegance includes a unmarried magnificence, the Applet class and 3 interfaces: AppletContext, AppletStub, and AudioClip.

 

JSP Tutorial
Question 14. What Is Appletstub Interface?

Answer :

The applet stub interface offers the way via which an applet and the browser talk. Your code will not commonly put into effect this interface.

Question 15. What Are The Applets Information Methods?

Answer :

The following are the Applet’s facts techniques:
getAppletInfo() method: Returns a string describing the applet, its author, copyright statistics, and so on.
GetParameterInfo( ) technique: Returns an array of string describing the applet’s parameters.

JMS(Java Message Service) Interview Questions
Question sixteen. What Are The Steps Involved In Applet Development?

Answer :

Following are the steps worried in Applet improvement:
? Create/Edit a Java source document. This document should comprise a class which extends Applet magnificence.
? Compile your program the use of javac
? Execute the appletviewer, specifying the name of your applet’s source report or html report. In case the applet data is stored in html file then Applet may be invoked the use of java enabled internet browser.

Java-Springs Tutorial
Question 17. Which Method Is Used To Output A String To An Applet? Which Function Is This Method Included In?

Answer :

drawString( ) technique is used to output a string to an applet. This technique is included in the paint technique of the Applet.

Java Interview Questions
Question 18. When Is Update Method Called?

Answer :

Whenever a display wishes redrawing (e.G., upon advent, resizing, validating) the replace method is called. By default, the replace technique clears the display screen after which calls the paint technique, which usually contains all of the drawing code.

J2EE Interview Questions
Question 19. How Will You Communicate Between Two Applets?

Answer :

The best technique is to apply the static variables of a shared elegance seeing that there is only one example of the class and subsequently only one reproduction of its static variables.
A barely extra reliable method is based on the truth that all the applets on a given web page proportion the same AppletContext.
We acquire this applet context as follows:
AppletContext ac = getAppletContext();
AppletContext provides applets with strategies together with getApplet(call), getApplets(),getAudioClip, getImage, showDocument and showStatus().

Java Tutorial
Question 20. How Do You Communicate In Between Applets And Servlets?

Answer :

We can use the java.Internet.URLConnection and java.Net.URL lessons to open a general HTTP connection and "tunnel" to the web server. The server then passes this statistics to the servlet inside the regular way. Basically, the applet pretends to be a web browser, and the servlet doesn't understand the distinction. As a ways because the servlet is worried, the applet is just another HTTP purchaser

Java 8 Interview Questions
Question 21. What Is The Base Class For All Swing Components?

Answer :

JComponent (besides pinnacle-degree bins)

Question 22. Why Do You Canvas?

Answer :

The Canvas magnificence of java.Awt is used to offer custom drawing and occasion managing. It offers a popular GUI thing for drawing photos and text on the screen. It does not help any drawing methods of its own, however gives access to a Graphics object via its paint() technique. The paint() method is invoked upon the introduction and update of a canvas in order that the Graphics item related to a Canvas object can be up to date.

Java 8 Tutorial
Question 23. What Type Of Sound File Formats Can I Use For The Applets?

Answer :

Java v1.02 handiest helps the "voice layout" of the .Au sound files. This is also recognise as "µ-law, 8/16-bit, mono, 8000hz sample rate"

Java Programmer Interview Questions
Question 24. Explain How To Read Information From The Applet Parameters.

Answer :

The getParameter() technique can be used in the init() technique to get right of entry to the parameter information.
It takes the parameter call as a controversy.
Example:
public void init()

   String val = getParameter("foreground-color");


Core Java Interview Questions
Question 25. What Are The Attributes Of Applet Tags?

Answer :

top : Defines top of applet
width: Defines width of applet
align: Defines the textual content alignment across the applet
alt: An trade textual content to be displayed if the browser aid applets however can not run this applet
archive: A URL to the applet whilst it's far stored in a Java Archive or ZIP document
code: A URL that points to the magnificence of the applet
codebase: Indicates the base URL of the applet if the code characteristic is relative
hspace: Defines the horizontal spacing around the applet
vspace: Defines the vertical spacing across the applet
call: Defines a call for an applet
object: Defines the resource name that includes a serialized representation of the applet
name: Display statistics in device tip
Question 26. How Can We Determine The Width And Height Of A Applet?

Answer :

Applet tags have attributes width and height with which we are able to determine their dimensions.
When applet is strolling inner an internet browser the size of an applet is ready by the height and width attributes and can not be changed by using the applet.
The 'getSize()' method is retrieved the scale of an applet.
The 'getSize()' approach is inherits from 'java.Awt.Component.GetSize()' and returns a 'java.Awt.Dimension object.
Question 27. What Are The Methods That Control An Applet’s On-display Appearance?

Answer :

The strategies that manipulate an applet’s on-display screen look I.E. Replace and paint.
- The paint() method is referred to as in conditions the applet window being overwritten by way of every other window or uncovered or the applet window being resized.
- The paint() is likewise called while the applet begins execution. The paint() technique has one parameter of kind Graphics which is needed to know the vicinity where the applet is meant to color its output.
- The update() is known as while a portion of its window be redrawn. It is defined by using the AWT.
- However, the replace() first fills an applet with the default heritage coloration and then calls paint() because of which an example of the default color appears each time update is called.
- Thus update() technique need to be overridden to avoid this case.

JSP Interview Questions
Question 28. How Would You Communicate Between Applets And Servlets?

Answer :

We can use the java.Net.URLConnection and java.Internet.URL training to open a standard HTTP connection and "tunnel" to a Web server. The server then passes this statistics to the servlet. Basically, the applet pretends to be a Web browser, and the servlet doesn't realize the distinction.
As a ways as the servlet is involved, the applet is just another HTTP purchaser. Applets can talk with servlets the use of GET or POST strategies. The parameters can be surpassed among the applet and the servlet as name value pairs. Objects can also be handed among applet and servlet using object serialization. Objects are serialized to and from the inputstream and outputstream of the relationship respectively.

 

Question 29. What Is A Signed Applet?

Answer :

A signed Applet is a depended on Applet.
By default, and for security reasons, Java applets are contained inside a "sandbox". This method that the applets cannot do something, which is probably construed as threatening to the person's system (e.G. Studying, writing or deleting nearby documents, putting up message windows, or querying various machine parameters).
Early browsers had no provisions for Java applets to attain outside of the sandbox. Recent browsers, but (Internet Explorer four on Windows etc), have provisions to give "relied on" applets the capability to work outdoor the sandbox. 
For this electricity to be granted to one in all your applets, the applet's code have to be digitally signed with your unforgeable digital ID, after which the person have to state that he trusts applets signed with your ID.
The untrusted applet can request to have privileges outside the sandbox however will need to request the person for privileges whenever it executes. But with the trusted applet the user can choose to do not forget their answer to the request, which means they may not be asked once more.
Question 30. Can You Write A Java Class That Could Be Used Both As An Applet As Well As An Application?

Answer :

Yes. Add a primary() method to the applet.




CFG