What happens when a main method is declared as private?
Answer Posted / kundan
when u will declare main method is private
it will successfully compile and Run
and result will publish,
class A
{
int x=7;
void show(){
System.out.println(x);
}
}
class Test
{
private static void main(String args[])
{
A a = new A();
a.show();
}
}
out put:-
Main method not public
Is This Answer Correct ? | 7 Yes | 4 No |
Post New Answer View All Answers
Where import statement is used in a java program?
What is the public field modifier?
What is variable declaration and definition?
What is the same as procedures?
What is difference between equal and == in java?
Why main method is static in java?
Which package is used for pattern matching with regular expressions?
Is a string literal?
What do you understand by classes in java?
What is the default size of set in java?
How to sort an array in java without using sort method?
Why do we use threads in java?
What is the difference between exception and error in java?
What is flush () in java?
How can you make sure that your singleton class will always return single instance in multi-threaded environment?