This week's book giveaway is in the Programmer Certification forum.
We're giving away four copies of OCP Oracle Certified Professional Java SE 11 Programmer I Study Guide: Exam 1Z0-815 and have Jeanne Boyarsky & Scott Selikoff on-line!
See this thread for details.
Win a copy of OCP Oracle Certified Professional Java SE 11 Programmer I Study Guide: Exam 1Z0-815 this week in the Programmer Certification forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Paweł Baczyński
  • Piet Souris
  • Vijitha Kumara

Sun certification 310-035

 
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello all -
I am taking the java certification exam by sun (310-035) in a couple of days. However, I am having a question with regards to the presentation of code in the exam.
If the code sarts from line 1, and does not start with a class declaration then should I consider it as the beginning of the code (in which case the compilation fails)?
Example:
1. int a=0;
2. public void foo(){
3. System.out.println("Foo");
4. }
as opposed to
1. public class A{
2. int a=0;
3. public void foo(){
4. System.out.println("Foo");
5. }
6.}
Please clarify me.
Regards.
 
Chicken Farmer ()
Posts: 1932
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch forjava!
First, and while glad to see your name is so dedicated to the language, it violates our Naming Policy. You need to have both a first and last name, and they must be realistic first and last names. We prefer people to use their own names, but if you aren't comfortable with this, make something up that looks real.
Second, since we have forums specifically for the SCJP exam, I'm moving this post there.
 
Ranch Hand
Posts: 384
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hey,
well if you come across some sort of question like this, i would tend to think that code below should be treated as if the previous code does not produce compilor errors:

I remember reading somewhere that you should definitely treat questions starting with say line 5 as the previous statements do compile, like:

But then again, I hope you get more answers to this question to set your mind at rest totally.
Davy
[ March 11, 2004: Message edited by: Davy Kelly ]
 
Sheriff
Posts: 4313
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the exam starts with a very explicit explanation about how to interpret questions and code snippets -- so don't stress about it too much. Remember, the exam is structured to test your knowledge, not to trick you into getting the wrong answer.
from what I remember, if code starts with line #1, you assume nothing -- and that all code given is everything that is in the actual file.
if code starts with another number (like line 3 or 12, you assume that the previous lines have stuff like import statements, package declaration, class declaration etc.
 
Hari priya
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi -
Thank you Jess and Davy for your clear replies. Thats a lot of help.

Best
[ June 12, 2007: Message edited by: Hari priya ]
 
If you believe you can tell me what to think, I believe I can tell you where to go. Go read this tiny ad!
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!