Explore BrainMass

Explore BrainMass

    Java: Fraction, Subclass, Number

    Not what you're looking for? Search our solutions OR ask your own Custom question.

    This content was COPIED from BrainMass.com - View the original, and get the already-completed solution here!

    From the program attached, perform each of the following experiments. Explain in a word document what happens when you do each operation and why this happens.

    1. "Comment out" one of the method declarations for class Fraction.
    2. "Comment out" the toString method in class Fraction
    3. Remove the comment in front of the line: // Number stupid = new Number();
    4. Remove the cast operation in the line: Number temp = (Number) nextS;

    See the attached file.

    © BrainMass Inc. brainmass.com March 4, 2021, 6:24 pm ad1c9bdddf


    Solution Preview

    Modified file attached.

    1. Fraction is not abstract and does not override <method> in java.lang.Number
    This error comes in because once the method declaration in commented out, it is no longer executed as a code. The ...

    Solution Summary

    The solution assists with using the Java program, and what happens when you do the given operations and why it happens.