Using OOP concept in java