• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Rob Spoor
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Scott Selikoff
Bartenders:
  • Piet Souris
  • Jj Roberts
  • fred rosenberger

javacertificate.com question

 
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I came across this question
_______________________________________________
What will happen if you try to execute the following code?

1. public static void Main(String args[]){
2. System.out.println ("Hello JavaCertificate");
3. }
1 Compilation succeeds, the output is Hello JavaCertificate.
2 Compilation succeeds, no output is generated.
3 Compilation fails, the definition of the main method does not specify a return type.
4 Compilation fails, the definition of the main method is incorrect.
5 None of the above
_______________________________________________

I was under the impression that when the lines are numbered starting from 1, then you should expect a complete file. If this was the case then this should not compile.
Should I expect to see questions like this on the exam? or will Sun stick to my above assumption?
BTW the correct answer is 5.
This is the explanation given
____________________________________________
The code will compile, the declaration of the name of the main method is incorrect, therefore no entry point is defined. At the moment the JVM tries to execute the code it searches for the main entry point, i.e. a method called main, this doesn't exists. The JVM throws a NoSuchMethodError. public static void main(String argv[]) is the correct syntax of the main method. Public means that the main method is visible from outside the package declaration. The static keyword means that the method belongs to the class and not to an instance of the class, there is no need to create an instance of the class. Void means that it does not return a value when finished executing. The name of the method is 'main' without capital letters. The method takes a String array in as arguments. The name of the argument list does not matter. The square brackets can come before or after the name of the array.

____________________________________________

I know and understand that this is not the correct method signature for a main method.
Because this does not display the entire file are we to assume that there is not another method
public static void main(String[] args){}?
 
Sheriff
Posts: 4313
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I was under the impression that when the lines are numbered starting from 1, then you should expect a complete file. If this was the case then this should not compile.
you are correct -- on the real exam -- if they're showing you only a *snippet* of the code -- like this one then the line numbers should start like at 8 (anything but 1). And if its a full file -- it will start at 1.
In order for this to compile AS IS -- it would need a "public class Blah {" line along with its corresponding closing curly brace.
Given that -- yes I'd say the quiz question/answer is incorrect.
 
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes you got a point there. If the line numbers start from 1, you should see the Class declaration.
That won't happen on the exam. If the line nos start from 1, you will see the whole file.
Else its a snippet of code.
Hope that helps.
Monisha.
 
stable boy
Posts: 425
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Indeed code fragments specified as the complete class file with line-numbers or code fragments that are only a snippet would not compile.
Indeed the real-exam does not provide line-numbers for code-snippets as far as I'm aware, but you can make a fair assumption on the real-exam that what is not there you can not assume either.
It seems to be that this question on Javacertificate.com has caused some question marks, our aim is to provide a dynamic testcentre and mock-exams that are as close to the real exam, therefore we will remove the line-numbers from the code-snippets.
We appreciate the feedback made on this question and other questions, it will only come to the benefit of the candidate for the SCJP Certification.
All the best.
http://www.javacertificate.com
The Javacertificate.com team
 
Cowgirl and Author
Posts: 1589
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Howdy all,
Just to clarify, the line numbers are ALWAYS on the code in version 1.4 (the latest) of the SCJP. The way it works is that if the line numbers start at 1, you are seeing a complete listing. If they start at something OTHER than 1 (and we chose the other starting numbers randomly, so don't assign any meaning to the line numbers that start at something other than 1), it means you are seeing a snippet of code, in other words, code extracted from some larger code listing.
Hope this helps
We keep trying to make things a little more clear with each revision of the exam...
cheers,
Kathy
 
Kathy Sierra
Cowgirl and Author
Posts: 1589
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Thomas De Vos:
[QB]Indeed the real-exam does not provide line-numbers for code-snippets as far as I'm aware, but you can make a fair assumption on the real-exam that what is not there you can not assume either.
It seems to be that this question on Javacertificate.com has caused some question marks, our aim is to provide a dynamic testcentre and mock-exams that are as close to the real exam, therefore we will remove the line-numbers from the code-snippets.


Howdy, please refer to my previous post, Thomas. The exam DOES include line numbers on snippets, so removing your line numbers from snippets is NOT a good solution if you want your exams to be like the real SCJP. They should simply start with a number that is not 1.
cheers,
Kathy
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic