|
|
Optimize with a SATA RAID Storage Solution
Range of capacities as low as $1250 per TB. Ideal if you currently rely on servers/disks/JBODs
These tips and cautions will help you write better programs and save you from agonizing over error messages produced by the compiler.
abstract keyword. Otherwise, the compiler reports an error.
Just as it is unwise to add new constants and/or method signatures to an interface, it is also unwise to remove those members. To see why, consider the following example:
Create an X.java source file that contains Listing 1's source code. That source file holds an interface declaration named X:
Listing 1. X.java
// X.java
interface X
{
void foo ();
}
Create a UseX.java source file that contains Listing 2's source code. That source file holds a class declaration that implements X:
Listing 2. UseX.java
// UseX.java
class UseX implements X
{
public static void main (String [] args)
{
X x = new UseX ();
x.foo ();
}
public void foo ()
{
System.out.println ("foo");
}
}
Compile both source files. Assuming you use the SDK tools for Windows, type javac UseX at the command line to create X.class and UseX.class.
Run UseX (by typing java UseX) and the program should run correctly.
Comment out void foo (); in X.java and recompile that source file (i.e., javac X.java).
Attempt to run the previously generated UseX.class file. This time, you will receive a runtime error message stating that a method -- foo(), to be exact -- cannot be found.
Now that the object-oriented language basics series has ended, it is time to test your knowledge of series material. To add some incentive for completing the quiz below, I've fashioned the questions into a reader challenge. Challenge winners will receive JavaWorld sweatshirts and t-shirts.
Here are the rules:
I've divided the quiz into four sections: