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

badly formatted code on exam?

 
Melissa Heeren
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In addition to preparing myself for the exam, I teach advanced high school students in a magnet program, and my top kids are going to sit for the exam. We're using a variety of resources to prepare, including LearnKey OnlineExpert and Enthuware. The sample questions on the Oracle site have "ugly" code - no indentation, etc. Is this what we'll see on the exam? When I'm trying to figure out ugly code, the first thing I do is format it to make it readable. If that's the game here we'll learn the rules and play to win. But I don't want to spend precious test prep time on something we won't face on the test. (FWIW, I've seen REALLY ugly real-world code - in various assembly languages :-) )

Thanks in advance.
 
Roel De Nijs
Sheriff
Posts: 10594
143
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Melissa Heeren wrote:Is this what we'll see on the exam?

Yes, it is.

Something like this code snippet could be easily on the exam (wrong indentation just to try to fool you):
 
Melissa Heeren
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually that seems fair. I'm talking about NO indentations, at all. Here are the samples I'm referring to:

public class Sequence {
Sequence() { System.out.print("c "); }
{ System.out.print("y "); }
public static void main(String[] args) {
new Sequence().go();
}
void go() { System.out.print("g "); }
static { System.out.print("x "); }
}

and

public class MyLoop {
public static void main(String[] args) {
String[] sa = {"tom ", "jerry "};
for(int x = 0; x < 3; x++) {
for(String s: sa) {
System.out.print(x + " " + s);
if( x == 1) break;
}
}
}
}

and


interface Rideable {
String getGait();
}
public class Camel implements Rideable {
int weight = 2;
public static void main(String[] args) {
new Camel().go(8);
}
void go(int speed) {
++speed;
weight++;
int walkrate = speed * weight;
System.out.print(walkrate + getGait());
}
String getGait() {
return " mph, lope";
}
}



etc. Basically, ALL of the sample questions on the Oracle site have NO indentation at all. That's not what I've seen on the practice tests so far - some trick nesting notwithstanding. Is this what we should expect on the exam?

Thanks,
MJH
 
Roel De Nijs
Sheriff
Posts: 10594
143
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Melissa Heeren wrote:Is this what we should expect on the exam?

In the previous exams I took (I didn't take the OCAJP 7 yet) such questions didn't appear on the exam, the code was always indented.

The Sequence class (in previous exams) will be presented as follows:
 
Melissa Heeren
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks - that's a lot better.
:-)
 
Mala Gupta
Author
Ranch Hand
Pie
Posts: 355
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Melissa,

As Roel mentioned, the code isn't very badly indented in the exam.

Oracle has confirmed that the incorrectly indented code in the sample questions at their website is a webpage display issue. You can scroll down the blog enty - Prepare For Your Oracle Certification At OpenWorld and JavaOne, at Oracle.com and look for confirmation comments by Brandye Barrington (from Oracle).

With respect,
Mala
 
Paul Anilprem
Enthuware Software Support
Ranch Hand
Posts: 3776
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Melissa,
We haven't observed messed up indentation in the real exam, unless the question tests something about indentation such as the if/else mentioned above. We don't have badly indented code in our mock exams for the same reason.

HTH,
Paul.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic