aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes main method Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "main method" Watch "main method" New topic
Author

main method

Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Do we have to declare main method always public!If this ques. comes in the exam what should be written true or false.
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Although it will compile and run without being public (an error in the JDK that will not be addressed) it is supposed to be public. The exam might ask something like what the standard signature of the main method must be (according to the books and mocks - I haven't tested yet).
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
To a question which reads:
Do we have to declare main method always public?
My Answer would be FALSE.
Also, I am by the fact that I could actually
run an application with a "private" main() method.
The following code runs and the output is:
Byte value is = 10

My understanding was that I will get an error
saying "main() method not found" or something
like that.
Am I missing something ?
Oh, wait! My copy of the JDK is missing
something ?
Thanks.
- satya

[This message has been edited by satya5 (edited May 05, 2000).]
Ajith Kallambella
Sheriff

Joined: Mar 17, 2000
Posts: 5782
Satya,
I too was in the same boat a few weeks ago and
got very very very
For the sake of the certification exam, it
is safe to assume the signature of the main
method is
<PRE>
public static void main ( String[] args ).
</PRE>
It is the gospel.
However, in reality it can have private or no
access specifier and it still works. It has
already been logged with SUN, and they have no
plans of fixing it. They don't think it is a
bug.
Hope it clears your confusion ( or does it
make you ??)

Ajith

[This message has been edited by Ajith Kallambella (edited May 05, 2000).]


Open Group Certified Distinguished IT Architect. Open Group Certified Master IT Architect. Sun Certified Architect (SCEA).
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944

Thanks.
You see, I had a hunch for that..."my copy of
JDK is missing something". Its not me missing
all the time you know.
Regds.
- satya
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Oh no all this is a big :confused what should we select if we get such a question in the exam?
kking
Ranch Hand

Joined: Mar 14, 2000
Posts: 30
If a generic question is asked concerning the construction of the main method (as in a fill in the blank question) you type:
public static void main(String [] args);
you may not have to type in the parameter list. In that case type...
public static void main.

[This message has been edited by kking (edited May 05, 2000).]
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944

unregistered:
I thought I answered the question asked by Sim.
Check my previous post above.
I would go with FALSE, if this was a TRUE/FALSE qutn.
If it was a fill in the blank, I would go with what
the KING says.
Regds.
- satya
Simran Thakur
Greenhorn

Joined: Mar 11, 2003
Posts: 5
Thanks friends for clearing my doubt.
sim
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: main method