Explore BrainMass
Share

Explore BrainMass

    Rewriting Codes in Java

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

    The following lines of code compile and run:

    JOptionPane jop = new JOptionPane( );
    jop.showMessageDialog("This is never done");

    However, I am told the above code would not be written by an experienced Java programmer because the showMessageDialog method is static within the class. How would a pro would write it?

    Also, how would you modify the following classes so class A inherits from class B, and class B inherits from class C?

    public class A
    {
    private int x;

    public A(int n)
    {

    x = n;

    }
    }

    public class B
    {
    protected int x, z;

    public B(int a, int b)
    {

    x = a;
    z = b;

    }
    }

    public class C
    {
    private String s;

    public C(String x)
    {

    s = x;

    }
    }

    © BrainMass Inc. brainmass.com October 10, 2019, 7:26 am ad1c9bdddf
    https://brainmass.com/computer-science/java/rewriting-codes-java-581409

    Solution Preview

    The following lines of code compile and run:

    JOptionPane jop = new JOptionPane( );
    jop.showMessageDialog("This is never done");

    However, I am told the above code would not be written by an experienced Java programmer because the showMessageDialog method is static within the class. How would a ...

    Solution Summary

    This solution involves modifying and rewriting codes. The lines of a code are compiled and run.

    $2.19