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
Outline the major features of java.
Is there any way to skip finally block of exception even if some exception occurs in the exception block?
What is java Applet?
What advantage do java's layout managers provide over traditional windowing systems?
Difference between character constant and string constant in java ?
How to print nodes of a Binary tree?
What does serializing data mean?
What are the major advantages of internal iteration over external iteration?
Why is it called a string?
What are the types of relation?
What is extension method in java?
Explain the significance of listiterator.
What value is a variable of the string type automatically initialized?
Why main method is called first in java?
What is a vararg?