can we overload main method?
Answers were Sorted based on User's Feedback
Answer / shrirang & chetak
yes , we can overlode main method but we can not override
main method
example :
class a
{
public void main()
{
System.out.println("0.00000000");
}
public static void main(String ar[])
{
a A=new a();
A.main();
}
}
| Is This Answer Correct ? | 13 Yes | 4 No |
Answer / pradeep
yes i agree with chetak. we can overload but we can't override
| Is This Answer Correct ? | 7 Yes | 3 No |
Answer / sujith.v.m
Yes,
Because signature is different in main function so it will be overloaded.
| Is This Answer Correct ? | 5 Yes | 2 No |
Answer / mounika
yes we can overload becoz we can use different signatures to main method
| Is This Answer Correct ? | 4 Yes | 2 No |
Answer / atul
class mainoverloaded
{
public void main()
{
System.out.println("Hey");
}
public void main(int a)
{
System.out.println(a);
}
}
class maind
{
public static void main(String ah[])
{
mainoverloaded m=new mainoverloaded();
m.main();
m.main(10);
}
}
please execute this code.it is execute correctly.
| Is This Answer Correct ? | 1 Yes | 0 No |
Answer / srinivaskumar.nimmana
Yes, we can... like this,
public static void main(String[] args){....}
pulbic void main(int a){....}
public static int main(flaot f){....}
public String main(string s){....}
in the above code public static void main(string[] args) executed as thread remaining methods are normal methods in our java class. in jvm p.s.v.main(string[] args) defined with thread so jvm always search for this syntax only.any other main() with diffrent parameters are consider as normal method
| Is This Answer Correct ? | 1 Yes | 1 No |
Tell some latest versions in JAVA related areas?
Which data type is a class in java?
What do you mean by default constructor in java?
What are access specifiers in java ?
0 Answers Akamai Technologies,
what is the difference between HashMap and Hashtable
17 Answers Value Labs, Virtusa,
Hey buddy.. can you please tell me about the use of marker interface? And is there any link between marker interface and factory methods? Thanks in advance.
What is object-oriented programming?
What are predicates in java 8?
What are filterstreams?
When is an object subject to garbage collection?
What is difference between overloading and overriding in java?
Does a class inherit the constructor of its super class?if it does, how can you hide that constructor? if it doesnot how can you call it from the sub class?