4 Use the Java ByteArrayOutputStream and PrintStream classes to redirect the Systemout output for

4. Use the Java ByteArrayOutputStream and PrintStream classes to redirect the System.out output for unit testing of the student search method below. private student student; private String id, name, age, email, course; public void setup() { student = new Student(id, name, age, email, course); } public void testSaveStudent() { // Your code here } private static void searchForStudent() { System.out.println("Enter the student ID to search:"); int searchId = Integer.parseInt(scanner.nextLine()); boolean found = false; for (Student student : students) { if (student.getId() == searchId) { found = true; System.out.println("Student found:"); System.out.println("ID: " + student.getId()); System.out.println("Name: " + student.getName()); System.out.println("Age: " + student.getAge()); System.out.println("Email: " + student.getEmail()); System.out.println("Course: " + student.getCourse()); break; } } if (!found) { System.out.println("Student not found."); } }

4. Use the Java ByteArrayOutputStream and PrintStream classes to redirect the System.out output for unit testing of the student search method below. private student student; private String id, name, age, email, course; public void setup() { student = new Student(id, name, age, email, course); } public void testSaveStudent() { // Your code here } private static void searchForStudent() { System.out.println(“Enter the student ID to search:”); int searchId = Integer.parseInt(scanner.

Read More