Professional Documents
Culture Documents
Lab 3
Lab 3
Source Code:
enum Department {
Department(String deptCode){
this.deptCode=deptCode;
return deptCode;
}}
for(Department dept:Department.values()){
} }}
Output:
4|Page
ADVANCE OBJECT ORIENTED PROGRAMMING 2020-CE-127
Task 4: Create enum for spade, heart, diamond, and club belonging to an enumerated type called
cards stored each of the enumerators in the reference variables a1,a2,a3,a4 respectively.
Source Code:
enum Cards
Cards a1 = Cards.spade;
Cards a2 = Cards.heart;
Cards a3 = Cards.diamond;
Cards a4 = Cards.club;
a3 + "," + a4);
Output:
5|Page
ADVANCE OBJECT ORIENTED PROGRAMMING 2020-CE-127
Task 5: created an enumeration called games with four enumerators(ludo, Chess, Badminton,
Cricket) initialize a for each loop (inside a class) and fetch the value of the enumerators.
Source Code:
enum Games
System.out.println("Games:");
System.out.println(g);
Output:
6|Page