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 Recursion Function?
What is array and arraylist in java?
What is string array?
What is thread safe singleton?
What is the use of StringTokenizer class?
What is collection class in java? List down its methods and interfaces.
How to declare objects of a class ?
Can we change the value of static variable?
Explain the difference between association, aggregation and inheritance relationships.
What is a loop java?
What is the difference between jfc & wfc?
How do you escape json?
Can we declare register variable as global?
What is the internal implementation of set in java?
What is difference overloading and overriding?