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
How garbage collection is done in java?
How to call one constructor from the other constructor ?
What is the differences between c++ and java? Explain
What are the actions that can occur when a thread enters blocked state?
How do you escape sequences in java?
Is an array a vector?
What is private static class in java?
Can a class be declared as static?
What are latest features introduced with java 8?
What is a void method?
What is array initialization in java?
What is methods in java?
What is a char in java?
Is zero a natural number?
What does int [] mean in java?