Set - 2

Question 11 :

When should the method invokeLater()be used?

Answer :

This method is used to ensure that Swing components are updated through the event-dispatching thread.


Question 12 :

How many methods in Object class?

Answer :

This question is not asked to test your memory. It tests you how well you know Java. Ten in total.
clone()
equals() & hashcode()
getClass()
finalize()
wait() & notify()
toString()


Question 13 :

How does Java handle integer overflows and underflows?

Answer :

It uses low order bytes of the result that can fit into the size of the type allowed by the operation.


Question 14 :

What is the numeric promotion?

Answer :

Numeric promotion is used with both unary and binary bitwise operators. This means that byte, char, and short values are converted to int values before a bitwise operator is applied.
If a binary bitwise operator has one long operand, the other operand is converted to a long value.
The type of the result of a bitwise operation is the type to which the operands have been promoted. For example:
short a = 5;
byte b = 10;
long c = 15;
The type of the result of (a+b) is int, not short or byte. The type of the result of (a+c) or (b+c) is long.


Question 15 :

Is the numeric promotion available in other platform?

Answer :

Yes. Because Java is implemented using a platform-independent virtual machine, bitwise operations always yield the same result, even when run on machines that use radically different CPUs.