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
Can we rethrow the same exception from catch handler?
Explain about static imports in java?
Program to Find the second largest element in an array.
What about abstract classes in java?
Can we declare the static variables and methods in an abstract class?
What does nextint () do in java?
What are scalar data types?
How many types of threads are there in java?
What is difference between equals and hashcode method?
How to print nodes of a Binary tree?
How big is a boolean?
Can you use abstract and final both with a method?
Why is method overloading not possible by changing the return type in java?
What is subsequence of a string?
What is immutable state?