Question: Write Java program Write a Java program to develop a public class Hobbies that has: Student Name Hobby Ali Swimming Bader Cycling Rana Reading Salma
Write a Java program to develop a public class Hobbies that has: Student Name Hobby Ali Swimming Bader Cycling Rana Reading Salma Reading 1. One private attribute: index as a HashMap where key is a String and value is a String. [3 marks) 2. A zero-argument constructor that initializes index to an empty HashMap. [2marks) 3. A public instance method called fillup() that takes no argument and return nothing. It fills index with the data in table above. [3 marks) 4. A public instance method called brint () that prints index one row per line. [3 marks) 5. A public instance method called lookUp (String h). This method returns nothing and print out the student names who has the same hobby as argument. [6 marks) 6. A public instance method number Element(), that takes no argument and returns number of rows in index. [2 marks] 7. A public instance method sorted () that takes no arguments and returns no value. IT should print out index's keys in alphabetical order. [3 marks) 8. Write a static main method, and write Java statement inside the main to do the following: (5 marks) Create an instance of Hobbies class named indexl in the main method. Use indexi instance to call fillup() method. Use index1 instance to call brint() method. Print out indexlin alphabetical order. Print out the number of rows in index1. Use index1 instance to print out the students names that has "reading" as their hobby Hint: Import the required libraries if needed
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
