[Q.no 37, sun pre-assesment test.. they dont give the answers ]
When class StaticStuff has been compiled, what is the result when you attempt to compile class FindStatic?
The code compiles.
Compilation fails due to an error on line 1.
Compilation fails due to an error on line 4.
Compilation fails due to an error on line 5.
Compilation fails due to an error on line 6.
Compilation fails due to errors on multiple lines.
I had chosen option1 but I think I was wrong...
Is it the option three?
Static import only imports the static member so there's no way to instantiate StaticStuff in FindStatic??
import static x.StaticStuff.*;
The compiler cannot recognize the StaticStuff.
Need to add import com.test.StaticStuff;
ss = new StaticStuff();
Although you have imported the static members, but to instantiate the StaticStuff class, you need to use the package name. Try using
ss = new x.StaticStuff();
It will compile fine.
Hope this helps