Question: In JAVA- Step 1---Create a File called ResultDB.txt having RorNo and Marks separated by space in each line. Insert appropriate values. Step 2---Create a class

In JAVA-

Step 1---Create a File called ResultDB.txt having RorNo and Marks separated by space in each line. Insert appropriate values.

Step 2---Create a class called Result.java having member variables rollNo and marks. Add appropriate constructor.

Step 3---Create a singleton class called StudentDAO.java having an array called results to store the Result objects of the file ResultDB.txt. Initialize the array in a static block so that it reads the file, create the Student object and store it in the results array during loading of the class StudentDAO.java. This singleton class maintains a maximum of 5 instances and return the instances in round robin fashion within getInstance() method. StudentDAO.java also has a non-static method with signature int getMarks(int rollNo) that queries the array and returns the corresponding marks.

Step 4---Create a class called ResultQuery.java that, within a loop, get an instances of StudentDAO.java using getInstance() method, print the instance returned, call getMarks() method with a random rollNo and print the marks.

-------------

Please provide the txt file (in written text form ofc) mentioned in the question.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!