- What is synchronization?- Synchronization is the mechanism that ensures that only one thread is accessed the resources at a time.
- When you will synchronize a piece of your code?- When you expect your code will be accessed by different threads and these threads may change a particular data causing data corruption.
- What is deadlock?- When two threads are waiting each other and can’t precede the program is said to be deadlock.
- What is daemon thread and which method is used to create the daemon thread?- Daemon thread is a low priority thread which runs intermittently in the back ground doing the garbage collection operation for the java runtime system. setDaemon method is used to create a daemon thread.
- Are there any global variables in Java, which can be accessed by other part of your program?- No, it is not the main method in which you define variables. Global variables is not possible because concept of encapsulation is eliminated here.
- What is an applet?- Applet is a dynamic and interactive program that runs inside a web page displayed by a java capable browser.
- What is the difference between applications and applets?- a)Application must be run on local machine whereas applet needs no explicit installation on local machine. b)Application must be run explicitly within a java-compatible virtual machine whereas applet loads and runs itself automatically in a java-enabled browser. d)Application starts execution with its main method whereas applet starts execution with its init method. e)Application can run with or without graphical user interface whereas applet must run within a graphical user interface.
- How does applet recognize the height and width?- Using getParameters() method.
- When do you use codebase in applet?- When the applet class file is not in the same directory, codebase is used.
- What is the lifecycle of an applet?- 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 maximized. stop() method - Can be used when the browser moves off the applet’s page. destroy() method - Can be called when the browser is finished with the applet.
Saturday, 24 September 2011
Interview questions
Labels:
Interview Questions
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment