Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

a doubt

 
priya selva
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
priya selva
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can v expect this type of ques in real exam too...
which version to use???
 
Dan Chisholm
Ranch Hand
Posts: 1865
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
priya selva
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Dan for ur detail info...its really helpful...
Also trying ur Mock exam....really tough ....
Thanks guys...
 
Dan Chisholm
Ranch Hand
Posts: 1865
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 104
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1865
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The correct answer for both exams is run time error.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic