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


Please Help Members By Posting Answers For Below Questions

What are different exception types exceptions available in java ?

468


What is stack explain?

495


How many types of java are there?

543


What do you mean by ordered and sorted in collections in java?

540


What is a dynamic array java?

503






What does exp mean in math?

522


What is arguments in java?

507


Can the interface be final?

566


What is a generic code?

520


Explain a few methods of overloading best practices in java?

496


What is scope & storage allocation of static, local and register variables? Explain with an example.

556


Can we overload run() method in java?

584


Can constructor return value?

503


Can we sort arraylist in java?

551


What is the arraylist in java?

519