Object oriented concept in java