ja5
- Write a Java Program to create the hash table that will maintain the mobile number and
student name. Display the details of student using Enumeration interface. [15 M]
import java.util.*;
public class StudentHashTable {
public static void main(String[] args) {
Hashtable<String, String> studentTable = new Hashtable<>();
studentTable.put("1234567890", "John");
studentTable.put("9876543210", "Alice");
studentTable.put("4567890123", "Bob");
Enumeration<String> mobileNumbers = studentTable.keys();
while (mobileNumbers.hasMoreElements()) {
String mobileNumber = mobileNumbers.nextElement();
String studentName = studentTable.get(mobileNumber);
System.out.println("Mobile Number: " + mobileNumber + ", Student Name: " + studentName);
}
}
}
- Create a JSP page for an online multiple choice test. The questions are randomly selected
from a database and displayed on the screen. The choices are displayed using radio
buttons. When the user clicks on next, the next question is displayed. When the user
clicks on submit, display the total score on the screen.
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
// Display questions and choices using radio buttons
for (int i = 0; i < questions.length; i++) {
out.println("<p>" + questions[i] + "</p>");
for (int j = 0; j < choices[i].length; j++) {
out.println("<input type='radio' name='answer" + i + "' value='" + choices[i][j] + "'> " + choices[i][j] + "<br>");
}
}
%>
<input type="submit" value="Submit">
</form>
</body>
</html>