Q51. How does Java handle integer overflows and underflows?
It uses low order bytes of the result that can fit into the size of the type allowed by the operation.
Q52. What is the numeric promotion?
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.
Q53. Is the numeric promotion available in other platform?
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.
Q54. 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.
Operator & has no chance to skip both sides evaluation and && operator does. If asked why, give details as above.
Q55. When is the ArithmeticException throwQuestion: What is the GregorianCalendar class?
The GregorianCalendar provides support for traditional Western calendars.
Q56. What is the SimpleTimeZone class?
The SimpleTimeZone class provides support for a Gregorian calendar.
Q57. How can a subclass call a method or a constructor defined in a superclass?
Use the following syntax:
super.myMethod();
To call a constructor of the superclass, just write super(); in the first line of the subclass's constructor.
Q58. What is the Properties class?
The properties class is a subclass of Hashtable that can be read from or written to a stream. It also provides the capability to specify a set of default values to be used.
Q59. What is the purpose of the Runtime class?
The purpose of the Runtime class is to provide access to the Java runtime system.
Q60. What is the purpose of the System class?
The purpose of the System class is to provide access to system resources.
No comments:
Post a Comment