May 21, 2008

Calendar Cubes

A corporate businessman has two cubes on his office desk. Every day he arranges both cubes so that the front faces show the current day of the month. What numbers are on the faces of the cubes to allow this?

I have come up with a solution which I would call "sly" and really "unfair"!

May 7, 2008

Difference between Singleton and Static implementations


(1) Static implementations cannot be extended(only static fields and methods can be extended) whereas Singleton implementations can be extended and its methods can be overridden.
(2) Static implementations cannot extend other class's instance fields/methods while Singleton implementations can.
(3) Static implementations must be initialized at the class loading time however Singleton implementations can be lazy initialized or asynchronously initialized.
(4) Static implementations cannot be initialized with a STATE (parameter), whereas Singleton implementations can be.
(5) Static implementations can still have instances (unwanted instances) whereas Singleton implementations prevents it.