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 is server side caching?
What is the longest unicode character?
How objects of a class are created if no constructor is defined in the class?
Can we override data members in java?
what is ststic with example
Can an anonymous class be declared as implementing an interface and extending a class in java programming?
How do you remove all elements from an arraylist in java?
What is a package in java? List down various advantages of packages.
What is the difference between length and length () in java?
How define set in java?
What is primitive data type in java?
How do I know if java is installed?
Can a constructor have different name than a class name in java?
List the different types of classloaders in java.
What are recursive functions?