Monday, February 26, 2007

What is a "stateless" protocol ?

Without getting into lengthy debates, it is generally accepted that protocols like HTTP are stateless i.e. there is no retention of state between a transaction which is a single request response combination


SOURCE : www.referjava.com

Difference between a Class and an Object ?

A class is a definition or prototype whereas an object is an instance or living representation of the prototype


SOURCE : www.referjava.com

What gives java it's "write once and run anywhere" nature?

Java is compiled to be a byte code which is the intermediate language between source code and machine code. This byte code is not platorm specific and hence can be fed to any platform. After being fed to the JVM, which is specific to a particular operating system, the code platform specific machine code is generated thus making java platform independent.


SOURCE : www.referjava.com

I made my class Cloneable but I still get 'Can't access protected method clone. Why?

Yeah, some of the Java books, in particular "The Java Programming Language", imply that all you have to do in order to have your class support clone() is implement the Cloneable interface. Not so. Perhaps that was the intent at some point, but that's not the way it works currently. As it stands, you have to implement your own public clone() method, even if it doesn't do anything special and just calls super.clone().


SOURCE : www.referjava.com

What is the purpose of the System class?

The purpose of the System class is to provide access to system resources.


SOURCE : www.referjava.com

How is rounding performed under integer division?

The fractional part of the result is truncated. This is known as rounding toward zero.


SOURCE : www.referjava.com

Is the ternary operator written x : y ? z or x ? y : z ?

It is written x ? y : z.


SOURCE : www.referjava.com

Can an object be garbage collected while it is still reachable?

A reachable object cannot be garbage collected. Only unreachable objects may be garbage collected


SOURCE : www.referjava.com

When can an object reference be cast to an interface reference?

An object reference be cast to an interface reference when the object implements the referenced interface.


SOURCE : www.referjava.com

What is the % operator?

It is referred to as the modulo or remainder operator. It returns the remainder of dividing the first operand by the second operand.


SOURCE : www.referjava.com

What is an object's lock and which object's have locks?

An object's lock is a mechanism that is used by multiple threads to obtain synchronized access to the object. A thread may execute a synchronized method of an object only after it has acquired the object's lock. All objects and classes have locks. A class's lock is acquired on the class's Class object.


SOURCE : www.referjava.com

What is the difference between a static and a non-static inner class?

A non-static inner class may have object instances that are associated with instances of the class's outer class. A static inner class does not have any object instances.


SOURCE : www.referjava.com