APPLETS Interview Questions in Java

We have compiled most frequently asked Java J2EE Interview Questions which will help you with different expertise levels.

Java J2EE Interview Questions on APPLETS

Question 1.
Define an applet in Java.
Answer:
There are two classes of programs in Java, namely, the applications and the applets. Applications are the normal programs while applets are small applications that are accessed on an Internet server, transported over the Internet, automatically installed, and run as part of a Web document.

Question 2.
What are the two packages that all applets must import?
Answer:

  1. java.applet; and,
  2. java.awt.

Question 3.
What do you understand by double buffering?
Answer:
Images are not only useful for storing pictures, but you can also use them as offscreen drawing surfaces. This allows you to render any image, including text and graphics, to an offscreen buffer which you can display later on. The main advantage of doing this is that the image is seen only when it is complete. Drawing a complicated image could take several milliseconds or more,

which can be seen by the user as flashing/flickering. This flickering/flashing is distracting and causes the user to perceive your rendering as slower than it actually is. The use of an offscreen image to reduce flicker is known as double buffering, since the screen is considered as a buffer for pixels, and the offscreen image is the second buffer, where you can prepare pixels for display.

Question 4.
What are the methods called in order when an applet begins and ends, respectively?
Answer:
When an applet begins, the AWT calls the following methods in order

  • init( )
  • start( )
  • paint( )

When an applet terminates/ends, the following order of methods comes into play:-

  • stop( )
  • destroy( )

Question 5.
What is Hotjava?
Answer:
Hotjava is a Web browser fully programmed in Java developed by the two Sun programmers, Patrick Naughton and Jonathan Payne. Hotjava enabled the running of Java applets on web pages. Subsequently, Java applets became implementable in other Web browsers such as Netscape Navigator.

Question 6.
Why is Java important to the Internet?
Answer:
Java’s ability to create and run applets and its portability because of its ability to create bytecodes to be run by the Java Virtual Machine (JVM) render it extremely suitable for the internet.

Question 7.
Does Java support pointers? If not, why not?
Answer:
Java does not support or allow pointers. The reason for that is simple. Java cannot allow pointers as by doing so, Java applets would be able to breach the firewall between the Java Runtime Environment and the host computer (this is because pointers can be assigned any address in memory – even those outside the Java runtime systems).

C/C++ programmers make extensive use of pointers and they might be inclined to think that their loss puts Java at a significant disadvantage. But, this is false. Java is designed in such a manner that as long as one stays within the boundaries of its execution environment, he will never feel the need to use a pointer. Moreover, he would not get any additional benefit by doing that either.
We must also add here that C/C++ code making use of pointers can be converted conveniently to Java code that makes no use of such pointers.

Question 8.
Can you enumerate the tag used to embed an applet into a WEB/HTML page?
Answer:
The relevant tag used is <APPLET>.

Question 9.
Where are the applets executed?
Answer:
Applets are executed by the applet engine similar in working to a virtual machine existing in the web browser at the client-side.

Question 10.
Enumerate the main points of difference between an application and an applet.
Answer:
There are basically two main points of difference between an application and an applet enumerated as under:-

1. Applets are useful for creating dynamic and interactive web applications. An applet runs under the control of a browser whereas an application runs as a stand-alone program on the desktop.

2. An applet is subjected to tougher security restrictions in terms of file and network access whereas an application can easily access the file system and network.