Code: Select all
What would be the result of attempting to compile and run the following program?
class TestClass{
static TestClass ref;
String[] arguments;
public static void main(String args[]){
ref = new TestClass();
ref.func(args);
}
public void func(String[] args){
ref.arguments = args;
}
}
and correct answer for above problem is that it will compile as here ref is static and invoking func(String args) will not be any problem.
can you show examples or scenarios by modifying the above example only as when it will show an error while accessing the main method?