could you run the java program without main method?
Answer Posted / a.d. vijaykumaran
Yes. static is powerful word in java because of within
static block inside we can define statement and then
System.exit(0); use this to avoid runtime error main thread
exception error.
class Beatme //we can use any abstract class or interface
{
static // we can't do throws Exception
{
System.out.println("A.D.Vijaykumaran");
System.exit(0);
}
}
and one disadvantage above the program as doesn't
define "System defined Exception r throws Exception" .
| Is This Answer Correct ? | 13 Yes | 2 No |
Post New Answer View All Answers
What is the difference between the size and capacity of a vector?
What are recursive functions?
Wha is the output from system.out.println(“hello”+null); ?
Where is const variable stored?
Can we clone singleton class in java?
Can we sort array in java?
How do you sort a string in java?
Can a private method of a superclass be declared within a subclass?
What is classname class in java?
What is difference between length and length() method in java ?
What is cr keyboard?
How do you access command-line arguments within the code?
Can we serialize singleton class?
What does split function do in java?
Explain the hierarchy of java exception classes?