Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more ➡
Download
Standard view
Full view
of .
Add note
Save to My Library
Sync to mobile
Look up keyword
Like this
103Activity
×
0 of .
Results for:
No results containing your search query
P. 1
Java Interview Questions

Java Interview Questions

Ratings: (0)|Views: 1,500|Likes:

More info:

Published by: sathish04021984@gmail.com on Nov 13, 2008
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See More
See less

03/26/2012

pdf

text

original

 
Question
What is the difference between an Applet and an Application?
(Applets)
Answer
The differences between an applet and an application are as follows:1. Applets can be embedded in HTML pages and downloaded over theInternet whereasApplications have no special support in HTML for embedding ordownloading.2. Applets can only be executed inside a java compatible container, such asa browseror appletviewer whereas Applications are executed at command line by java.exe or jview.exe.3. Applets execute under strict security limitations that disallow certainoperations(sandbox model security) whereas Applications have no inherent securityrestrictions.4. Applets don't have the main() method as in applications. Instead theyoperate on anentirely different mechanism where they are initialized by init(),started bystart(),stoppedby stop() or destroyed by destroy().
 
Question
What are the Applet's Life Cycle methods? Explain them?
(Applets)
Answer
Following are methods in the life cycle of an Applet:init() method - called when an applet is first loaded. This method is calledonly once in the entire cycle of an applet. This method usually intializethe variables to be used in the appletstart() method - called each time an applet is startedpaint() method - called when the applet is minimized or refreshed. Thismethod is used for drawing different strings, figures, and images on theappletwindowstop() method - called when the browser moves off the applet’s pagedestroy() method - called when the browser is finished with the applet
 
Question
What is the sequence for calling the methods by AWT for applets?
(Applets)
 
Answer
When an applet begins, the AWT calls the following methods, in thissequence:init()start()paint()
 
When an applet is terminated, the following sequence of method callstakes placestop()destroy()
 
Question
How are the differences between Applets and Applications?
(Applets)
Answer
Application:-Applications are Stand Alone and do not need web-browser.-Execution starts with main().-May or may not be a GUI.Applets-Needs no explicit installation on local machine. Can be transferred throughInternet on to the local machine and may run as part of web-browser.-Execution starts with init() method. Must run within a GUI (Using AWT /Swing)
 
Question
How do we pass a parameter from HTML page to Applet?
(Applets)
Answer
[html][applet code="Launch.class" archive="bak.jar" width=740 height=460][param name="lang" value="English"][/applet][/html]And within the init() of your applet, Use the following line to get the value.String langs = getParameter("lang");
 
Question
When an user wants to send an int from HTML what does he needs todo?
(Applets)
Answer
Either the user wants to send an int or a String, it will be the same. Hereare steps he might do to get an int[html][applet code="Launch.class" archive="bak.jar" width=740 height=460][param name="mynum" value="098765"][/applet][/html]And within the init() of your applet, Use the following line to get the value.String mynum = getParameter("mynum");int x = Integer.parseInt(mynum);
 
 
Question
How can I arrange for different applets on a web page to communicatewith each other?
(Applets)
Answer
Name your applets inside the Applet tag and invoke AppletContext’sgetApplet() method in your applet code to obtain references to the otherappletson the page
 
Question
How do I go from my applet to another JSP or HTML page?
(Applets)
Answer
Use AppletContext and invoke showDocument() on that context object.Below is sample codeURL targetURL;String URLString = "http://localhost:8080/mypage.jsp";AppletContext context = getAppletContext();try{targetURL = new URL(URLString);}catch (MalformedURLException e){e.printStackTrace();}context.showDocument(targetURL);
 
Question
How do I determine the width and height of my application?
(Applets)
Answer
Use the getSize() method, which the Applet class inherits from theComponent class in the Java.awt package. The getSize() method returnsthe size of the applet as a Dimension object, from which you extract separate width,height fields. The following code snippet explains this:Dimension dim = getSize();int appletwidth = dim.width();int appletheight = dim.height();
 
Question
Which classes and interfaces does Applet class consist?
(Applets)
Answer
Applet class consists of a single class, the Applet class and threeinterfaces: AppletContext, AppletStub, and AudioClip
Question
What is AppletStub Interface?
(Applets)
Answer
The applet stub interface provides the means by which an applet and thebrowser communicate. Your code will not typically implement this interface
 
Question
What tags are mandatory when creating HTML to display anapplet?
(Applets)
Answer
code, height, width
 
Question
What are the methods to retrive information about an applet?
(Applets)

Activity (103)

You've already reviewed this. Edit your review.
1 hundred reads
1 thousand reads
steveirvin liked this
bruckner liked this
Vishal Gupta liked this
Gaurav Kumar liked this
bijayendra23 liked this
Subho Mukherjee liked this
mohanasurapaneni liked this
navalluri liked this

You're Reading a Free Preview

Download
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->