Question: (in java programming language) given the following class: public class Student implements Serializable { private int id; private String name; private int birthYear; private char
(in java programming language)
given the following class: public class Student implements Serializable { private int id; private String name; private int birthYear; private char gender; //value 'M' or 'F' private double gpa; Student(int id, String name, int birthYear, char gender) { this.id = id; this.name = name; this.birthYear = birthYear; this.gender = gender; } public int getBitrhYear() { return birthYear; } public double getGPA() { return gpa; } public char getGender() { return gender; } }
Create a separate test class with name testii having the following: a) A static method printFile that takes a string f1 representing a serial file name of Student objects and print all objects inside that file. b) A static int method countRecord that takes a string f1 representing a serial file name of Student objects and return number of objects inside that file. c) A static method filterStudents that takes a string f1 representing a serial file name of Student objects and separate male and female students into separate binary files with names male.ser and female.ser. d) A static double method sumGPA that takes a string f1 representing a serial file name of Student objects and return sum of GPA for all students inside that file. e) A main method that creates a binary file with name student.ser of seven Student objects. Then i. Print the file student.ser (using a call to printFile method). ii. Call method filterStudents. iii. Print files male.ser and female.ser (using two calls to printFile method). iv. Calculate GPA average for males and female (using methods countRecord and sumGPA).
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
