nullcan be assigned to any reference type.
@Overrideannotation provides compiler checking.
this, or a call to the super class constructor using
super. If not called explicitly, a call to the no-parameter super constructor is inserted by the compiler.
Casting an object reference is necessary when the compiler can't tell that the actual object is of the needed type. The cast creates a runtime check to make sure. There are two cases where a cast is required:
Object ob = "abc"; // No cast needed to assign up hierarchy. String s = ob; // BAD. Requires a cast String s = (String)ob; // Required.
All Strings are Objects, but not all Objects are Strings.
Comparable com = "def"; // No cast to assign to implemented interface String s = com; // BAD. Requires a cast. String s = (String)com; // Required.
All Strings are Comparables, but not all Comparables are Strings.