John Wintermute

Greenhorn
+ Follow
since Nov 01, 2011
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by John Wintermute

Zwakele Mgabhi wrote: Passed the OCJP6 exam today, time to celebrate.



Well done! Now you can have a rest
11 years ago

Lorenzo Tagliaferro wrote:Now it works!!! :-))

Thank you so much John!!!

I hope to repay you soon!!!



It's my pleasure I spent quite a while experimenting with this topic, moving files around, creating JAR files and generally trying lots of variations. It certainly helped in the exam.

Lorenzo Tagliaferro wrote:Excellent explanation!! :-)

But, if i try to launch the application i receive the "infamous" error: (wrong name: org/example/console/ConsoleExample)

I've tried to digit this command: java -cp classes\org\example\console\;classes\org\example\exception ConsoleExample

Thank you so much!



Hi there

You need to tell 'java' the fully-qualified name of the class you're trying to run, which in this case is org.example.console.ConsoleExample. The JVM knows that this class must be in a file called ConsoleExample.class, and it must be in a folder structure org\example\console because of the package name. The -cp option tells it where to find the 'org' folder

So your full command should be: java -classpath classes org.example.console.ConsoleExample

Cheers, John

Lorenzo Tagliaferro wrote:I have another issue!

I'm not able to launch the application by the shell!!!

I receive an error to find or load the main class.

This is the command: C:\Console\java -classpath classes ConsoleExample

Someone can help me?! Please!



OK, you've given the JVM the correct classpath, now you have to give it the fully-qualified name of the class you're trying to run The above command line would only work if ConsoleExample.class file was in the 'classes' folder, and was not part of any package. As an experiment, copy ConsoleExample.class into 'classes', run the same command line and you'll get a different error (something like 'wrong name').


(If my clue above wasn't enough, try "C:\Console\java -classpath classes org.example.console.ConsoleExample )
Hi there

I think your classpath is wrong. Instead of "-cp classes\org\example\exception" try instead "-cp classes". Your LoginException class should have compiled into classes\org\example\exception. It must be in this directory, because its package is org.example.exception - if it's not there, then check how you're compiling the class.

When you're compiling ConsoleExample, the compiler works out the path org\example\exception from the import declaration - you just need to set the classpath to be the folder above 'org', which in your case is 'classes'

cheers, john

Priyadarshan Kelkar wrote:Is Serialization and wait(),notify() topic included for OCJP 6 ?
As per the certification objectives they are not included, but they are mentioned in K&B book.
Please suggest. Thanks in advance.



They are not in the exam. The K&B book was printed before the topics were removed. In the K&B Practise Exam book, which was printed recently, they state that the Serialization topic is removed. They warn that some test centres were using versions of the test that included Serialization, but hopefully those are all gone by now.

cheers, john

Keith Rainey wrote:That's an outstanding score, John! Congratulations!

I agree that understanding WHY an answer is correct is vastly more important than just knowing it IS correct.



Thanks very much Keith - and belated congrats to you too! I'll raise a glass to you later

-john
13 years ago

Keith Rainey wrote:I'm happy to say I passed the OCPJP 6 certification exam today with 85%!



Hi Keith, from South East London UK - I took the exam this morning and almost fainted when I got 93%

I used both the Sierra/Bates and the Mughal/Rasmussen books for studying, created lots of sample code along the way. The MasterExam with the S/B book was a great help, especially as you can select how many questions you want - great for when you have 5 minutes to spare. However I think what really helped me was the Bates' Practice Exam Book (thanks Bert ;) ) - I was getting only 50% or so of the questions right but working through every question and understanding them really helped. Although I'm not sure I'll ever work out that "Organic<E>" question

Experiment with your code samples too, seeing what happens when you try different things. I also found it useful to mix other areas into a question, especially formatting. So instead of using "System.out.println(x)" use a static import and use 'out.format("The %2$s is >%1$-7d<", x, "answer")' etc. It helps cement those topics so they become second nature.

Good luck to everyone working towards the exam

Cheers, John
13 years ago

Bert Bates wrote:How about if main() throws exception?



Hi there,

Are you saying we can assume that, when the individual lines are added, that main() might change to accommodate the change? It makes questions hard to answer as it's a little ambiguous.

I hope there's not too many like that on the exam! But I suppose that, if we're told how many answers to select, then B and D are the only possible choices other than C and F, so we'd have to choose them.

Cheers, john
13 years ago
Hi Thomas,

Yes, you are indeed correct - it's how many are eligible when the method ends. Another case of "read the question properly"

thanks!

john
13 years ago
I think it might be five String objects, because on the last line, a + b + a1, first there will be a String for "a + b", and then another that adds that String to 'a1'.

What does everyone think?

cheers, john
Hi Larsen.

The '6' is the result of the regex finding a zero match after the last character.

Try using "ab" as the matcher String, and you;ll get the output "012" - one zero match before the first character, one between each character, and one after the last character.

'3' is not output because that's the index between the '3' and the '4' digits - the regex is treating the '34' as a match and consumes both digits.

Try printing out the matched group, with brackets around it so you can see the empty matches, and enter various values for the match:



(It took me a while to understand this strange regex behaviour )
Hi all,

When I worked through this question, I ended up with five objects, but the answer says it's only four. It seems to me that one Banker, one Account and three Longs are created



I ran the code through the debugger in Eclipse and, indeed, Long instances are created with different IDs at lines 1,2 and 3.

Would anyone care to comment on that?

Many thanks!
-john
13 years ago
Hi there,

That question got me too. I think it's because the assignment of integer values is atomic, so that line 8 always executes as one instruction. Doesn't seem intuitive though, as that line is both reading a variable and writing it again.

In the real exam, we are told how many answers are correct, so we'd have to make a best guess and assume D is not right. However, it's a pain not really understanding why D is incorrect.

I got the question wrong cos I missed the static/non-static bit.

cheers, john
13 years ago