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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started