| |
Section 1: Declarations and Access Control
An example of creation of instance of an inner class from some other class:
class Outer
{
public class Inner{}
}
class Another
{
public void amethod()
{
Outer.Inner i = new Outer().new Inner();
}
} |
| |
Section 2: Flow Control, Assertions, and Exception Handling
The setClassAssertionStatus() returns a boolean instead of throwing an exception, if it is invoked when it's too late to set the assertion status (i.e., if the named class has already been initialized). |
| |
Section 3: Garbage Collection
Garbage collection in Java cannot be forced. The methods used to call garbage collection thread are System.gc() and Runtime.gc(). |
| |
Section 4: Language Fundamentals
There are three top-level elements that may appear in a file. None of these elements is required. If they are present, they must appear in the following order:
- package declaration
- import statements
- class definitions
|
| |
Section 5: Operators and Assignments
The short circuit logical operators && and || provide logical AND and OR operations on boolean types and unlike & and |, these are not applicable to integral types. The valuable additional feature provided by these operators is that the right operand is not evaluated if the result of the operation can be determined only after evaluating the left operand. |
| |
Section 6: Overloading, Overriding, Runtime Type, and Object Orientation
A static method can't be overridden to non-static and vice versa. |
| |
Section 7: Threads
There are two ways to mark code as synchronized:
Synchronize an entire method by putting the synchronized modifier in the method's declaration.
Synchronize a subset of a method by surrounding the desired lines of code with curly brackets ({}). |
| |
Section 8: Fundamental Classes in the java.lang Package
The Math class has a private constructor, it cannot be instantiated. |
| |
SECTION 9: THE COLLECTIONS FRAMEWORK
The main difference between Vector and ArrayList is that Vector is synchronized while the ArrayList is not. |