-
Everything from the start marker of a comment block
(e.g. /*) is ignored until the first occurrence of
the matching end marker (*/).
-
The "throw" statement can only
throw "Throwable" objects. A NullPointerException
will be thrown if the Exception given to the "throw" statement results in
null.
-
In the
same statement you can use decimal, octal and/or
hexadecimal statements.
-
While
creating a multidimensional array, dimensions must
be created left to right. So,
int [] [] array = new
int [] [4]; is not valid.
-
Elements of an un-initialized array object get the
default value corresponding to the type of the
elements. Whether the array object reference is a
local or member variable, does not matter.
-
In a
switch statement the
type of the case labels must be assignable to the
type of switch
expression.
-
It is
not possible to break out of an "if" statement. If the "if" statement is placed
within a labeled block, a
switch statement or a loop construct, the
usage of "break" would
be valid.
-
The "if" statement does not return
any value.
-
"continue" cannot be used
outside the context of a loop.
-
A
variable declared in a "try"
block is not visible in "catch"
or "finally" block.
-
If C
extends B and B extends A, then it is not possible
to call a method of A ( implemented in all the three
classes ) from an instance method in class C.
-
An
object that has been eligible for garbage collection
may stop being eligible for garbage collection and
return to normal life. This happens if the call to
the finalize() reestablishes a reference from the
active part of the program to the object.
-
If a
class has a final blank
variable, then it must be initialized when an
instance is created ( in all the constructors or any
initializer ) , or else the code will fail to
compile.
-
A
thread's status (user or daemon) can be changed
before the thread is started. Changing the status of
a thread already started throws
IllegalStateException.
-
An
exception which is not thrown in the "try" block (for example,
thrown in a "catch"
block) is not handled by subsequent "catch" blocks, but will
rather be sent to the caller of the method. Before
this happens, "finally"
block is executed. Subsequent code after "finally" remains unreached if
that exception remains uncaught after the execution
of "finally" block.
-
If two
or more interfaces declare a variable with the same
name, then a class implementing these interfaces
cannot refer to that variable by its simple name as
it leads to ambiguity (even if the values of the
variable is same in both the interfaces ). The
ambiguity can be avoided by using fully qualified
names e.g. Interface1.varName and
Interface2.varName.
-
An
object can be eligible for garbage collection even
if there are references pointing to the object, as
long as the objects with the references are
themselves eligible for garbage collection.
-
The
unary post-fix operators and all binary operators,
except for assignment operators, associate from left
to right. All other operators associate from right
to left.
-
Floating point modulo (%) by zero produces NaN , but
floating point divide by zero does not.
-
Integer division truncates to the next lower integer
value in the absolute sense, but division by right
shifting truncates to the next lower integer value
in an algebraic sense. So, -7/2 == -3 but -7 >> 1 ==
-4.
-
Native
methods cannot be "abstract",
or "strictfp".
-
An
abstract method cannot
be static,
final,
synchronized,
native,
private, or
strictfp.
-
After
a thread has started, it will continue to run even
if its reference is set to null. A running thread
has a reference in a ThreadGroup even if your
program does not retain one. Thus a running thread
is never garbage collected.
-
A
NullPointerException is thrown when an application
attempts to use null in a case where an object is
required.
-
A null
reference may be used to access a
static variable or
method.
-
A
local class cannot have any access modifier.
-
The "this" variable is not a
normal reference variable that can be changed by
statements like this =
new A(); "this"
cannot be used to refer to local variables.