GeekInterview.com
Series: Subject: Topic:
Question: 35 of 995

Call Main Function Explicitly

Can we call the main function explicitly? If Yes, How?
Asked by: sahil5 | Member Since Jun-2010 | Asked on: Jun 21st, 2010

View all questions by sahil5

Showing Answers 1 - 1 of 1 Answers
Raghunadh Parlapalli

Answered On : Feb 13th, 2013

Thats an excellent question.
Try this, It works. Because main() is a static method. So, We can call static methods from another class static method.

ClassB {
public static void main(String[] args) {
System.out.println("ClassB main() Called");
}
}

ClassA {
public static void main(String[] args) {
System.out.println("ClassA main() Called");
ClassB.main(args);
}
}

  
Login to rate this answer.

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

Related Open Questions

Ads

Connect

twitter fb Linkedin GPlus RSS

Ads

Interview Question

 Ask Interview Question?

 

Latest Questions

Interview & Career Tips

Get invaluable Interview and Career Tips delivered directly to your inbox. Get your news alert set up today, Once you confirm your Email subscription, you will be able to download Job Inteview Questions Ebook . Please contact me if you there is any issue with the download.