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
What are different exception types exceptions available in java ?
What is stack explain?
How many types of java are there?
What do you mean by ordered and sorted in collections in java?
What is a dynamic array java?
What does exp mean in math?
What is arguments in java?
Can the interface be final?
What is a generic code?
Explain a few methods of overloading best practices in java?
What is scope & storage allocation of static, local and register variables? Explain with an example.
Can we overload run() method in java?
Can constructor return value?
Can we sort arraylist in java?
What is the arraylist in java?