could you run the java program without main method?
Answer Posted / rammohan
with out main() and static block also run java program
through static obj creation
class nomainnostatic
{
nomainnostatic()
{
System.out.println("vaaniMohan");
System.out.println("hai");
System.exit(1);
}
static nomainnostatic n=new nomainnostatic();
};
support some jdk versions only
exp:when ever static obj is created the default constructor
will be called,so the constructor block will be executed.
Is This Answer Correct ? | 1 Yes | 0 No |
Post New Answer View All Answers
How do you square a number in java?
What is the difference between menuitem and checkboxmenu item?
What are different exception types exceptions available in java ?
How does queue work in java?
What are the advantages of assembly language?
What do you mean by order of precedence and associativity?
What is a Hash Table? What are the advantages of using a hash table?
What is a method declaration?
How many bytes is string in java?
For ease of programming you can consider the maze as a 2D array with colors represented by below integer and characters (in capital letters). • B - Black • W -White • G- Green • R- Red R B W B W W W W W W B W B B W W W W W W W B W B W W W B W W W W B B W W W B W W W B W W B B B B W B W B W W B W W W B W W W B B B W W B W W W B W W B W B W W W B W B W W W W B B W W W W B W W W W W G Shortest Route Problem: • Solution that finds the shortest Route between Red and Green White will have 1 Weight. Red and Green carry no weights. Shortest path is the path with less weight when you add up the weights in the path.
Why 1 is not a prime number?
What is public static void main?
Explain restrictions for using anonymous inner classes?
What is the default value of local and global variables?
How do you compare two objects?