Jun
2007

What are some alternatives to inheritance?

Delegation is an alternative to inheritance. Delegation means that you include an instance of another class as an instance variable, and forward messages to the instance.

Jun
2007

What is the advantage of the event-delegation model over the earlier event-inheritance model?

The event-delegation model has two advantages over the event-inheritance model. First, it enables event handling to be handled by objects other than the ones that generate the events (or their containers). This allows a clean separation between a component’s design and its use.

Jun
2007

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.

Jun
2007

What is casting?

There are two types of casting, casting between primitive numeric types and casting between object references. Casting between numeric types is used to convert larger values, such as double values, to smaller values, such as byte values.

Jun
2007

What is the difference between a while statement and a do statement?

A while statement checks at the beginning of a loop to see whether the next loop iteration should occur. A do statement checks at the end of a loop to see whether the next iteration of a loop should occur. The do statement will always execute the body of a loop at least once.

Jun
2007

Why are there no global variables in Java?

Global variables are considered bad form for a variety of reasons:

  • Adding state variables breaks referential transparency (you no longer can understand a statement or expression on its own: you need to understand it in the context of the settings of the global variabl

May
2007

How to define an Interface?

In Java Interface defines the methods but does not implement them. Interface can include constants.

May
2007

How to define an Abstract class?

A class containing abstract method is called Abstract class.

May
2007

What is similarities/difference between an Abstract class and Interface?

Differences are as follows: * Interfaces provide a form of multiple inheritance. A class can extend only one other class. * Interfaces are limited to public methods and constants with no implementation.

May
2007

Is Iterator a Class or Interface? What is its use?

Iterator is an interface which is used to step through the elements of a Collection.