Search This Blog

Thursday, December 08, 2005

Java Interview Questions Part 5

What is a native method?
A native method is a method that is implemented in a language other than Java.

What are order of precedence and associativity, and how are they used?
Order of precedence determines the order in which operators are evaluated in expressions. Associatity determines whether an expression is evaluated left-to-right or right-to-left

What is the catch or declare rule for method declarations?
If a checked exception may be thrown within the body of a method, the method must either catch the exception or declare it in its throws clause.

Can an anonymous class be declared as implementing an interface and extending a class?
An anonymous class may implement an interface or extend a superclass, but may not be declared to do both.

What is the range of the char type?
The range of the char type is 0 to 2^16 - 1.

What is the purpose of finalization?
The purpose of finalization is to give an unreachable object the opportunity to perform any cleanup processing before the object is garbage collected.

What is the difference between the Boolean & operator and the && operator?
If an expression involving the Boolean & operator is evaluated, both operands are evaluated. Then the & operator is applied to the operand. When an expression involving the && operator is evaluated, the first operand is evaluated. If the first operand returns a value of true then the second operand is evaluated. The && operator is then applied to the first and second operands. If the first operand evaluates to false, the evaluation of the second operand is skipped.

Is “abc” a primitive value?
The String literal “abc” is not a primitive value. It is a String object.

What restrictions are placed on the values of each case of a switch statement?
During compilation, the values of each case of a switch statement must evaluate to a value that can be promoted to an int value.

What is the query used to display all tables names in SQL Server (Query analyzer)?
select * from information_schema.tables


What is garbage collection?
What is the process that is responsible for doing that in java? - Reclaiming the unused memory by the invalid objects. Garbage collector is responsible for this process

What kind of thread is the Garbage collector thread?
It is a daemon thread.

What is a Marker Interface?
An interface with no methods. Example: Serializable, Remote, Cloneable

What interface do you implement to do the sorting?
Comparable


What are the Applet’s Life Cycle methods? Explain them?
Following are methods in the life cycle of an Applet:
init() method - called when an applet is first loaded. This method is called only once in the entire cycle of an applet. This method usually intialize the variables to be used in the applet.
start( ) method - called each time an applet is started.
paint() method - called when the applet is minimized or refreshed. This method is used for drawing different strings, figures, and images on the applet window.
stop( ) method - called when the browser moves off the applet’s page.
destroy( ) method - called when the browser is finished with the applet.

What is the sequence for calling the methods by AWT for applets?
When an applet begins, the AWT calls the following methods, in this sequence:
init()
start()
paint()

When an applet is terminated, the following sequence of method calls takes place :
stop()
destroy()

No comments: