- an empty source file will compile without error
- if a .java file does not contain a public class or interface it can have any name
- a single-type import will take precedence over an import-on-demand
- import-on-demand types do not increase the size of the compiled code ie only the types actually used are added to the code
- while import-on-demand adds no overhead to the compiled code, they can slow down the speed of the compile
- a constructor body can include a return statement providing no value is returned
- any method can throw a Runtime or Error exception without declaring it in the throws clause
- methods having the same name and parameter types do not have the same signature unless the parameter types are listed in the same order
- main() can be declared final
- main() is inherited and can be overridden if not declared as final
- args[0] references first command line argument after the application name ( arrays in Java are zero-based)
- main() can be declared public static void ... or static public void ...
- the variable name does not have to be args; can be anything as long as the type is String[]
- variables can have the same name as a method or a class
- only field variables are automatically initialized to their types default value; local variables must be explicitly initialized
- arrays are initialized to the default value of their type when they are created, not declared, even if they are local variables
- array index operator [] has highest level of precedence
- integer variables can be used as array dimension values
- postfix/prefix operators have the highest level of precedence
- remember that when the postfix operator is used in an expression, the current value of the variable is used
- a class may be assigned to an Interface type if the class implements the interface or one of it's sub-interfaces
- you cannot cast a primitive type to an object reference, or vice versa
- you cannot cast a boolean type to another primitive type
- String operations whose result does not alter the original string (ie calling toUpperCase() on a String that is already in uppercase) return the original string reference; otherwise they return a reference to a new String
- Strings are immutable; the original String value can never be changed
- all the primitive type wrapper classes override the Object.equals() method to compare the value of the objects; the default Object.equals() method checks if the variables reference the same object
- you do not have to have a default statement in a switch() block
- the default statement in a switch() block can appear anywhere in the construct, does not have to be last
- all sections of the for() loop are optional
- finalize() can only be executed once on any object
About Java and it's related concepts..
Comments
Post a Comment