Here's a Java class with one line, which declares a local variable called x, replaced with a comment.
Compiling and running the class gives the following output:
What is the missing line?
If you can't work out the answer immediately, a secondary question: what can you say about the data type of x?
Code:
public class Test {
public static void main(String[] args) {
// Missing line of code declaring local variable x...
System.out.println("Test starting...");
if (x != x) {
System.out.println("Unpossible!");
}
System.out.println("Test finished.");
}
}
Compiling and running the class gives the following output:
Code:
Test starting...
Unpossible!
Test finished.
What is the missing line?
If you can't work out the answer immediately, a secondary question: what can you say about the data type of x?