This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Soft Skills and have John Sonmez on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes a doubt Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "a doubt" Watch "a doubt" New topic
Author

a doubt

priya selva
Greenhorn

Joined: Feb 21, 2002
Posts: 29
public class one
{
final static void main(String args[])
{
System.out.print(0x011 + 0100 - 11);
}
}

in a mock exam the ans given is 70 ...
but when i compile this code gives
main must be public and static....
help me...is that due to jdk version?....
Val Lee
Ranch Hand

Joined: Nov 27, 2001
Posts: 41
I try it.
In 1.3.1_04 version, the output is 70.
In 1.4.1 version, the output is main method not public.


Val SCJP2 1.2<br />====>SCJD
priya selva
Greenhorn

Joined: Feb 21, 2002
Posts: 29
can v expect this type of ques in real exam too...
which version to use???
Dan Chisholm
Ranch Hand

Joined: Jul 02, 2002
Posts: 1865
The Java Language Specification Section 12.1.4 Invoke Test.main states the following.
The method main must be declared public, static, and void. It must accept a single argument that is an array of strings.

A mock exam should test your understanding of the Java Language Specification. In this specific case, the mock exam should also verify that you know that the Java Virtual Machine enforces this rule--not the compiler.
Some older versions of the JDK do not enforce the rule. Even so, a mock exam should not promote the use of coding practices that violate the Java Language Specification. For the purposes of the exam, any declaration of the main method that is syntactically correct but in violation of the requirement to declare the main method as described in Section 12.1.4 of the JLS results in a run time error even if some versions of the JDK don't enforce the specification.


Dan Chisholm<br />SCJP 1.4<br /> <br /><a href="http://www.danchisholm.net/" target="_blank" rel="nofollow">Try my mock exam.</a>
priya selva
Greenhorn

Joined: Feb 21, 2002
Posts: 29
Thanks Dan for ur detail info...its really helpful...
Also trying ur Mock exam....really tough ....
Thanks guys...
Dan Chisholm
Ranch Hand

Joined: Jul 02, 2002
Posts: 1865
Priya,
Thank you for the feedback.
Yes, most everyone that has written to me has said that my mock exam is more difficult than expected. For that reason, I have been working on developing new questions for the section titled "Basics" on the "Topic Exam" page. I would like to provide more easy questions for those that are just getting started and save the more difficult questions for those that are nearly ready for the real exam. That should allow both beginners and advanced programmers to get something of value from my mock exam page.
I hope to get the next version of my exam up on the web within the next few days. It will probably have another 15 or 20 questions for the "Basics" section and about the same number of new questions for the other sections.
The next version will also have a new section titled "New Questions". All of my questions are developed in a set of XML files--one xml file for each topic. Since the source documents are xml, I can use JDOM and XSLT to distribute the questions across the html documents any way that I like. In the next version of the exam, I'll sort out the new questions and put them into a separate document. The new section will allow people to come back to the mock exam to work through only the new questions.
zarina mohammad
Ranch Hand

Joined: Jun 26, 2002
Posts: 104
in a mock exam the ans given is 70 ...
but when i compile this code gives
main must be public and static....

so if such a question appears in SJCP exam version 1.2 should the answer be 70? and runtime error if it appears in exam version 1.4??
Dan Chisholm
Ranch Hand

Joined: Jul 02, 2002
Posts: 1865
The correct answer for both exams is run time error.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: a doubt