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
How to restrict a member of a class from inheriting by its sub classes?
What is the applet security manager, and what does it provide?
Can we make a constructor final?
A non-static inner class may have object instances that are associated with instances of the class’s outer class. A static inner class does not have any object instances.
Explain the difference between abstract class and interface in java?
what is collatration?
What is a java string?
How do you convert string to int in java?
what is meant wrapper classes?
Differentiate between array list and vector in java.
What is the effect of keeping a constructor private?
What is the purpose of void class?
What are the properties of thread?
How to change the priority of thread or how to set priority of thread?
Why string is immutable or final in java