Louie van Bommel

Ranch Hand
+ Follow
since Aug 17, 2004
Merit badge: grant badges
For More
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Louie van Bommel

There are a lot of questions here, so I'm going to take a stab at the one in the title. A persistence unit is needed to tell the EntityManager which class you need to persist. Now I think you might be asking why did the designers of JPA decide to make it necessary to have a persistence unit. If that's your question, then my answer is that it makes your application more resilient to changes to persistence providers. For example, if you used JPA and coded your application to use Derby as the database, switching it over to MySQL as a database would be simple; it's just a matter of specifying MySQL in one configuration file (persistence.xml). I'll leave the other parts of your question for others.

Originally posted by Amit Das:
where can i find

Marcus's exams are reachable from:


That link came from the nifty faq (scjp certification faq)for this forum:
It was 3 months for me. About 2 hours every weekday. I used K&B as my source. I did ALL the questions in it, and coded absolutely every single thing that I doubted or was unclear on. That's a good idea.

Then I took the exams with the book, then took 3 of Marcus' exams. That was sufficient for preparation.

(I also went overboard by doing most of Dan's questions which are very in-depth, and read most of Mughal & Rasmussen too: quite a bit overkill)

I'll repeat. Read every word in K&B, do K&B's questions. And code at least 100 examples.
[ March 14, 2005: Message edited by: Louie van Bommel ]

Originally posted by ramya jp:
[QB]A class inside an interface is always public and static and cannot call the methods declared in the interface...compiles without an error,even though the inner class A is abstract.QB]

True. The class inside an interface is always public and static. To prove that it's public, try compiling it with a "private" qualifier. The compiler will tell you that it has to be "public".

To prove it's static (the dreaded static nested class), compile it with the static keyword, and run javap A on it. Look at the results. Then compile it without the static keyword. run javap A on it. Compare the results. It's the same bytecode!!!

To answer your question why your example compiles correctly, you've shown an example of a nested class in an interface. The compiler compiles it as a static and public class. Your class just happened to be an abstract class. It's still public and static. It just happens to be abstract.

If you want to write some code that proves the third point, write (something) like this [I don't have a compiler handy]

In this example I'm trying to call a method in the interface from a static nested class. Compiler won't allow it.

Any class you create in an interface (whether it's an abstract class or a fully implemented class) is a static nested class. Static nested classes can't access any instance methods nor variables from their "enclosing" classes.

I hope that clears that up. Furthermore K+B don't cover classes inside interfaces in their book, that should give you some idea of how relevant it is for the exam (hint: it's not, imho!).
I just wrote my Sun Certified Java Programmer 5.0 Beta exam. Here are my comments:

- The material was quite easy. Much easier than I expected.
- The exam was long. I hit a wall at 100 minutes (out of 300) and I kinda developed a "I just don't care any more" attitude. If you can endure the five hours, you'll likely do better.
- My preparation was thoroughly studying K+B for SCJP 1.4 and then looking at the exam objectives, looking at the java docs for the stuff that was new, and coding some new java 5.0 stuff. That was certainly sufficient.
- Some questions were very much like Kathy and Bert's suggestions in their book.
- Some questions were asking precicesly the same thing as a previous question.
- Some questions were impossible to review coz there's a weird glitch that when a draggy/droppy window pops up for an answer, you can't really review it without erasing your answer (thereby wasting time and discouraging me from reviewing). I put that in my comments tho.

-Louie (glad I stuck it out for the 5 hours )
19 years ago

As you can see (above new results line), it still prints out a ?, not the � (capital E with accent)
19 years ago
No extra ports needed. Just plain old port 80 (the HTTP port). It must be a configuration problem in the browser... like disabling java or something.

It's not a port problem. I've had web servers with ONLY port 80 open, and they spew out java applets like there's no tomorrow.
19 years ago
I can't seem to do this, as you can see in my code. It's supposed to output a value of 0x90 but it outputs a value of 0x5B when I look at the results of my output in a binary/hex dump.

it's supposed to show a capital E with an accent but it shows a question mark. When I spew the output to a file and look at that file in a hex dump, the value of that question mark is 0x5B (or 91 decimal). it should be 144 decimal or 0x90.

Q: how do I do an output statement correctly? The specs require me to write out unsigned byte data to a file with values of 144 and such.
19 years ago
My previous post holds true and I recommend to do it that way rather than the following. However, to specifically answer your questions in your situation:

4. I moved the Java source file finaltest.java from c:\john to c:\john\final.
5. From the command Prompt I compiled like c:\john\final\javac finaltest.java

Mistake in 4 is moving the source. Leave the source in the same place. I assume in 5 you mean that you typed javac c:\john\final\finaltest.java. In reality it doesn't matter where the heck the source is so you might as well leave it where it was. And compile it there too. You COULD do the following.

4. Leave source in c:\John
5. from command prompt javac finaltest.java
5B. move the COMPILED file finaltest.class into the finalpkg subfolder (this is what some java books say to do, but my previous post has an easier way)

7. When I run this like c:\john\final\java finaltest
I am getting ... error

What you need to do is from the parent folder you need to run it, and use dots, not slashes. So from the folder ABOVE the finalpkg folder, type:

java finalpkg.finaltest

Do I need to create Sub Directory with the Packge name and need to place the souce file ?
Is there something I am missing in Classpath settings ?

I always create a subdirectory, but I think javac -d . will create one for you. Try it. However you shouldn't place the source file in that directory. Compile it in the normal directory, and move the COMPILED file to the subdirectory. (or see previous post and save the trouble)

And forget about the classpath. You don't need to modify the classpath to work with java packages.
When time runs out, it scores what you've gotten so far. (Automatic in other words).
[ November 03, 2004: Message edited by: Louie van Bommel ]
Save yourself a whole lot of trouble and try

java -d . Finaltest.java

But that's assuming you follow these steps:

Create a subfolder called finalpkg in the current folder.
Create a source file Finaltest.java with "package finalpkg"
java -d . Finaltest.java

This compiles to Finaltest.class and puts it in the subfolder finalpkg.

Run it with
java finalpkg.Finaltest (from the current folder)
[ November 03, 2004: Message edited by: Louie van Bommel ]
Here's an article on their usefulness/uselessness


And Flanagan said:

"Nested top-level classes and interfaces are typically used as a convenient way to group related classes."

More here:
Caught: garbage collected at end of catch block.
Thrown: garbage collected at end of block where it's finally caught.

The Exception object is created within the catch block and its lifetime ends at the end of the block. It's similar to the lifetime of a variable in an initialized for loop:

The lifetime of i is the block in which it is used.

An exception

The exc object is created in the catch block and its lifetime is that block. Therefore it's free for garbage collection as the block finishes.
[ October 26, 2004: Message edited by: Louie van Bommel ]