Random classes and program in java