OOP concept demo written in Java