Geeks Talk

Prepare for your Next Interview


Welcome to the Geeks Talk forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact us.

Declare main method as private

This is a discussion on Declare main method as private within the Java forums, part of the Software Development category; If we declare the main method as private instead of public it will execute or not...

Go Back   Geeks Talk > Software Development > Java
Register Blogs FAQ Tag Cloud Calendar Mark Forums Read

Java Java related Issues and Problems

Reply

 

LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-17-2007
Junior Member
 
Join Date: Apr 2007
Location: Delhi
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
rajesh.tripathi is on a distinguished road
Declare main method as private

If we declare the main method as private instead of public it will execute or not
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 07-17-2007
Contributing Member
 
Join Date: Sep 2006
Location: bangalore, india
Posts: 1,016
Thanks: 0
Thanked 91 Times in 72 Posts
psuresh1982 will become famous soon enough
Re: hi

No error on complile time. But you got the run time error like "main method is not public".

--------------------
suresh
Reply With Quote
  #3 (permalink)  
Old 09-13-2007
Junior Member
 
Join Date: May 2006
Location: Bangalore
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Ramesh409 is on a distinguished road
Re: hi

No...because,execution will start from main itself....it needs to accessable by anywhere....
Reply With Quote
  #4 (permalink)  
Old 09-14-2007
Contributing Member
 
Join Date: Sep 2006
Location: bangalore, india
Posts: 1,016
Thanks: 0
Thanked 91 Times in 72 Posts
psuresh1982 will become famous soon enough
Re: Declare main method as private

hi ramesh,

Are you trying for this one? Don't you get error at run time?

-------------------
suresh
Reply With Quote
  #5 (permalink)  
Old 09-14-2007
Junior Member
 
Join Date: Sep 2007
Location: Bangalore
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
harijava79 is on a distinguished road
Smile Re: Declare main method as private

No U cant declare main method as Private.
During runtime it gives no such method error.
Reply With Quote
  #6 (permalink)  
Old 09-18-2007
Junior Member
 
Join Date: Sep 2007
Location: dallas
Posts: 3
Thanks: 0
Thanked 1 Time in 1 Post
srinivasdumpala is on a distinguished road
Re: Declare main method as private

hi ,

In run time,jvm checks main method with this convention(public static void main(String args[]) )
if you dont define this method as actually defined, JVM shows run time error as no such method.it wont execute any statement of any other main method.
Reply With Quote
  #7 (permalink)  
Old 09-20-2007
Junior Member
 
Join Date: Sep 2007
Location: New Delhi
Posts: 5
Thanks: 0
Thanked 1 Time in 1 Post
softvijay is on a distinguished road
Re: Declare main method as private

Quote:
Originally Posted by rajesh.tripathi View Post
If we declare the main method as private instead of public it will execute or not
NO it will not execute, normally main method is executed by JRE Interpretor
Making it private would not provide access to JRE.

vj
Reply With Quote
  #8 (permalink)  
Old 09-24-2007
Junior Member
 
Join Date: Aug 2007
Location: Mumbai
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
jayantp3 is on a distinguished road
Re: Declare main method as private

Dear Rajesh,

The Main Method will not execute if you will declare as private . It should be public .

Regards,
Jayant





Quote:
Originally Posted by rajesh.tripathi View Post
If we declare the main method as private instead of public it will execute or not
Reply With Quote
  #9 (permalink)  
Old 10-03-2007
Junior Member
 
Join Date: Feb 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
freedeus is on a distinguished road
Re: Declare main method as private

One can declare the main method as private, but a main method with private access specifier will not be treated by the java runtime, as entry point of the program.
Reply With Quote
Reply

  Geeks Talk > Software Development > Java

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads

Thread Thread Starter Forum Replies Last Post
java program without main method BHASKAR CHAUHAN Java 6 10-31-2008 02:06 PM
How to declare Global variables in QTP by using vb script? Geek_Guest QTP 1 08-28-2008 12:13 PM
How to declare variables in SP? bharathi_ark SQL Server 4 10-01-2007 08:38 AM
I would like to declare the log variable for class B archanadadhich Java 1 08-30-2007 07:21 AM


All times are GMT -4. The time now is 12:36 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.3.1
Copyright © 2009 GeekInterview.com. All Rights Reserved