Difference between revisions of "Instantiation"

From Suhrid.net Wiki
Jump to navigationJump to search
Line 5: Line 5:
 
* Every constructor as its first statement has a call to this() or super().
 
* Every constructor as its first statement has a call to this() or super().
 
* Compiler will only automatically insert call to no-arg super() or this().
 
* Compiler will only automatically insert call to no-arg super() or this().
* CANNOT call an instance method or access instance variables till the super constructor has run.
+
* '''CANNOT call an instance method or access instance variables till the super constructor has run.'''
 
* Only Static variables can be accessed as a call to super() or this().
 
* Only Static variables can be accessed as a call to super() or this().

Revision as of 05:12, 16 August 2011

Constructors

  • Every class - including Abstract classes - MUST have a constructor.
  • Constructor chaining is built in. Every class constructor will call its default superclass constructor using super().
  • Every constructor as its first statement has a call to this() or super().
  • Compiler will only automatically insert call to no-arg super() or this().
  • CANNOT call an instance method or access instance variables till the super constructor has run.
  • Only Static variables can be accessed as a call to super() or this().