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 is file in java?
what is predefined function in java?
What is the scope or life time of instance variables?
How to print an arraylist in java?
How many bits are used to represent unicode, ascii, utf-16, and utf-8 characters?
Can we initialize the final blank variable?
Why is inheritance used in java?
Which package is imported by default?
enlist some features of jdk.
What does java ide mean?
What are the supported platforms by java programming language?
How to make a read-only class in java?
What are filterstreams?
What does %d do in java?
Why we override equals() method?