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


Please Help Members By Posting Answers For Below Questions

What does bitwise or mean?

673


What do you mean by scope of variable?

570


What is a type parameter in java?

635


What is meant by inheritance and what are its advantages?

686


Is null a keyword in java?

633






What is hashing in java?

670


What are synchronized methods ?

709


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?

1128


How do you declare an array that will hold more than 64KB of data?

774


What is boolean keyword in java?

727


define polymorphism in java

723


What is the list interface in java programming?

667


Assume a thread has lock on it, calling sleep() method on that thread will release the lock?

738


What does %4d mean in java?

1015


Does windows 10 need java?

697