posted 19 years ago
First of all, I am using textpad to compile and run (No command prompt).
file name Test.java:
class Zip {
public void go() {
System.out.println("Zip");
}
}
public class Test {
public static void main(String[] args) {
System.out.println("Test");
Zip z = new Zip();
z.go();
}
}
1. When I compile and run the above program it prints:
Test
Zip
2. When I make both classes default, compile and run it still prints:
Test
Zip
3. If I make Zip class public and Test class default, change the name of the file to Zip.java, compile and run it throws java.lang.NoSuchMethodError exception.
4. Now if I make both classes default again, compile and run it throws the same exception java.lang.NoSuchMethodError.
Now the question is:
Program contents are same in scenarios 2 and 4 then why different output?
Thanks