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 does bitwise or mean?
What do you mean by scope of variable?
What is a type parameter in java?
What is meant by inheritance and what are its advantages?
Is null a keyword in java?
What is hashing in java?
What are synchronized methods ?
Class c implements interface I containing method m1 and m2 declarations. Class c has provided implementation for method m2. Can I create an object of class c?
How do you declare an array that will hold more than 64KB of data?
What is boolean keyword in java?
define polymorphism in java
What is the list interface in java programming?
Assume a thread has lock on it, calling sleep() method on that thread will release the lock?
What does %4d mean in java?
Does windows 10 need java?