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

Should you use singleton pattern?

731


What is the size of arraylist in java?

798


What is method with example?

804


describe method overloading

733


Is main an identifier?

784


What is string pool in java?

786


What is an arraylist in java?

736


Is main a keyword in java?

762


Explain public static void main(string args[]).

875


What is protected in java?

763


which is advanced deep technology in java launched by the sun microsystem??? The answer is very logical If u need correct answer mail me at priya_gupta@gmail.com

3446


State the difference between strings and arrays.

881


how we can make a read-only class in java?

777


Why is java so important?

894


What is the default value of local and global variables?

855