1. What is final?
A final class can't be extended ie., final class may not be subclassed. A final method can't be overridden when its class is inherited. You can't change value of a final variable (is a constant).
2. What if the main method is declared as private?
The program compiles properly but at runtime it will give "Main method not public." message.
3. What if the static modifier is removed from the signature of the main method?
Program compiles. But at runtime throws an error "NoSuchMethodError".
4. What if I write static public void instead of public static void?
Program compiles and runs properly.
5. What if I do not provide the String array as the argument to the method?
Program compiles but throws a runtime error "NoSuchMethodError".
6. What is the first argument of the String array in main method?
The String array is empty. It does not have any element. This is unlike C/C++ where the first element by default is the program name.
7. If I do not provide any arguments on the command line, then the String array of Main method will be empty or null?
It is empty. But not null.
A final class can't be extended ie., final class may not be subclassed. A final method can't be overridden when its class is inherited. You can't change value of a final variable (is a constant).
2. What if the main method is declared as private?
The program compiles properly but at runtime it will give "Main method not public." message.
3. What if the static modifier is removed from the signature of the main method?
Program compiles. But at runtime throws an error "NoSuchMethodError".
4. What if I write static public void instead of public static void?
Program compiles and runs properly.
5. What if I do not provide the String array as the argument to the method?
Program compiles but throws a runtime error "NoSuchMethodError".
6. What is the first argument of the String array in main method?
The String array is empty. It does not have any element. This is unlike C/C++ where the first element by default is the program name.
7. If I do not provide any arguments on the command line, then the String array of Main method will be empty or null?
It is empty. But not null.
No comments:
Post a Comment