Purchase Solution

Rewriting Codes in Java

Not what you're looking for?

Ask Custom Question

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;

}
}

Purchase this Solution

Solution Summary

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

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 ...

Purchase this Solution


Free BrainMass Quizzes
Excel Introductory Quiz

This quiz tests your knowledge of basics of MS-Excel.

C# variables and classes

This quiz contains questions about C# classes and variables.

C++ Operators

This quiz tests a student's knowledge about C++ operators.

Basic Computer Terms

We use many basic terms like bit, pixel in our usual conversations about computers. Are we aware of what these mean? This little quiz is an attempt towards discovering that.

Word 2010: Table of Contents

Ever wondered where a Table of Contents in a Word document comes from? Maybe you need a refresher on the topic? This quiz will remind you of the keywords and options used when working with a T.O.C. in Word 2010.