Free Jobs
Reference




Java Forums: Core Java (15) J2EE (3) EJB (5) Servlet (3) JDBC (6) Hibernate (2) Struts (1) Swing (1) Oracle (7) JSP (4) Other (10)

Topic: Write a java programme with out using main method

To get the Posted Questions details daily in your mail Click Here

Share this Post on Facebook/Twitter/Orkut Bookmark and Share





User: animelapurush Post Date: 31 Jan 2011 22:10

Introduction:
With out using main() it is impossible to write java programme but it is possible to write java programme with out using main().



Main Content:
here the following has a simple java programme...
class Demo
{
static
{
System.out.println("Hi....Purush");
System.exit(0);
}
}
the above programme is executed and display the message "Hi....Purush".here the static is called at the starting of the jvm before calling the main().that's way java will execute and the System.exit(0) is used to terminate the Exception main() not found...

Conclusion:
we can use java programme with out using main() we can't accept the data from user at run time in this above programme..



About Writer:


Writer's Link:

Writer's Email:







Comments:
  • User: pravindilpak@rediff.com Post Date:   29 Apr 2011 05:10
    we can not run the java program without main method


  • User: bhuvana178 Post Date:   05 Oct 2011 13:08
    very nice....intersiting


Post Comment





Similar Articles Top ArticlesLatest Articles Other Articles by this Author







www.freejobsreference.com Copyright © 2009-2011 | All Rights Reserved
All content of this website is protected by copyright laws and should not be reproduced in any form or by any means without written permission
(Best viewed in IE 8.0+ or Firefox 3.0+ at resolution of 1024 * 768 or higher)