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
Is java a security risk?
what is thread? : Java thread
What is finally and finalize in java?
What is the difference between instanceof and isinstance?
Can I uninstall java?
Can we use catch statement for checked exceptions?
What is the difference between iterator and enumeration ?
What is difference between static variable and global variable?
What is the simpletimezone class in java programming?
Can extern variables be initialized?
What is array class in java?
How do you find the maximum number from an array without comparing and sorting?
What is difference between class and object in java?
What are the characteristics of java?
Can we override private constructor in java?