Question
Consider the following class: public class Fraction{ private int numerator; private int denominator; private static char slash = /, } Write a program to instantiate
Consider the following class: public class Fraction{ private int numerator; private int denominator; private static char slash = /, } Write a program to instantiate an object of the Fraction class to test the class.. Add a constructor(s), set and get methods to the Fraction class appropriately. Using the Serializable Interface, instantiate and write three Fraction objects to a file called SerialF.dat. A loop must be used when creating and writing the three objects to the file. You can select the values you wish to use for the denominator and numerator. Directions Create the Fraction Class. o Add a constructor(s), set and get methods to the Fraction class appropriately. o Ensure the class is Serializable. Use a loop to create three Fraction objects. o Initialize the three objects, o Write each object to the fileSerialF.dat. Display an appropriate message if an exception occurs
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