constructors vs blocks code example
Example: constructors vs blocks
constructor: instance of the class.
private constructor (Driver class) ==> singleton class
constructor can only be called within another constructor
constructor will be executed when the object is created
can be overloaded cannot be overridden
static block: belongs to the class
executed as soon as the class is loaded
only gets executed once.
instance block: belongs to the object
gets executed when the object is created
executed before constructor