Sunday, October 16, 2016

Java Gotchas.


  • A default constructor without any parameters has to be provided if you have another constructor with parameters.
  • "!" only applies to booleans.
  • All interface methods have to be defined when you implement the interface into a class.
  • When you assign sub-class to parent-class handle, the compilation will pass but the methods available are in parent class code. It is during the run-time, the reference would actually point to the child class's overriding methods.
  • Constructors should never have static members.
  • During compilation, a stack of codes/data/pointers are built. The real memory space is allocated in the "Heap".
  • Static {}, namely initial static block will be called before any static methods.

No comments:

Post a Comment