Task 6a - Enums


Define two enums for Gender and Month. Gender is enumeration of two values i.e. Male and Female. and Month is enumeration of January, February, ... up to December. Month enum shall also store the number of days of each month.

Define User class with id, name, gender and birthMonth attributes. Use above created enums for gender and birthMonth. Create an object of User class, initialize by user input (gender shall be initialized by constructor and birthMonth shall be initialized by set method), and print all attributes values of user object.



Define EnumTest class, in main method, iterate the Month enum (created in 6a.1) to print all months' names and number of days of each month. Also iterate the Month enum to print subset of list e.g. Sep to Dec.


Popular posts from this blog

Task 12 - Create Java Program with MySQL Database Connectivity

Java Interfaces and Exception Handling - Practice Problem with Solution

Task 16 - Javafx Program to Create, Retrieve, Update and Delete records with Database