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

Which way a developer should use for creating thread, i.e. Sub classing thread or implementing runnable.

511


Is space a character in java?

506


For class CFoo { }; what default methods will the compiler generate for you>?

606


What do you mean by hashing?

639


can rmi and corba based applications interact ?

656






What is a singleton in genetics?

555


Name few java util classes introduced with java 8 ?

491


Is java platform independent?

559


Can a static block throw exception?

649


What are the different http methods?

519


Can you explain the cs option of java interpreter?

499


What do you mean by formatting?

536


What about instanceof operator in java?

592


What is compareto?

535


What is the abstraction?

578