Serge Plourde

Ranch Hand
+ Follow
since Jun 23, 2000
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 Serge Plourde

The HashTable Class is a Dictionary subclass which maps keys to values.

It is a quick way of storing and retrieving objects by key value. Note that the keys can be any object.

The hash key is the object that you will use to get to an object.


This will result in output:
Country full name of U.S.A is United States of America
Thanks guys, I think then it is better to do an earlier exam.

For you that need the syllabus of scjp:
If you take a look at the Java API Doc, you'll see that: TreeMap, IMap, Map,
and HashTable are not in the list of subinterfaces or implementing classes.

Interface Collection<E>

All Superinterfaces:

All Known Subinterfaces:
BeanContext, BeanContextServices, BlockingQueue<E>, List<E>, Queue<E>, Set<E>, SortedSet<E>

All Known Implementing Classes:
AbstractCollection, AbstractList, AbstractQueue, AbstractSequentialList, AbstractSet, ArrayBlockingQueue, ArrayList, AttributeList, BeanContextServicesSupport, BeanContextSupport, ConcurrentLinkedQueue, CopyOnWriteArrayList, CopyOnWriteArraySet, DelayQueue, EnumSet, HashSet, JobStateReasons, LinkedBlockingQueue, LinkedHashSet, LinkedList, PriorityBlockingQueue, PriorityQueue, RoleList, RoleUnresolvedList, Stack, SynchronousQueue, TreeSet, Vector
Is there any book already available for Sun Certified Programmer for the Java 2 Platform, Standard Edition 5.0 (CX-310-055), or CX-310-056?

Hi all!

I now have some JUnit tests that fail, whereas it used to pass, since I switched to Java 5.

Here is a code excerpt:

It turns out that iv2.amountPaid value is 5.1500000000000003552713678800500929355621337890625
and iv2.totalAmountWrittenOff is 1.25

If I try to update the table, it crashes with an overflow.

Why is this hapening and how can I correct this?

18 years ago
Alan Jump:

a class that implements an interface must define all methods contained in that interface

False A class that implements an interface can implement some, but not all of the interface's methods, if that class is declared abstract. Of course, there will come a time that some subclass, somewhere down the inheritance tree, will have to implement the rest of the methods still to implement!

Please, don't hit your head on the wall like that. We all learn!!!

I know that (K&B book) on the exam we wont be asked to make esoteric dinstictions between keywords and manifest consants: null,true & false.
i assumed the JVM identifies keywords by boldfacing them(if theres such a thing) and this is what happens with manifest constans as well.
why not just make them keywords, anyone with a clue?

I don't think it is the JVM that handles this but rather the compiler.

null, true and false are not constants but literals of the boolean type and the null type, as stated below.

The keywords help the compiler to parse the code with the different elements of the language, and the literals are used to assign values. So, I don't think that you can mix those two different things up.

From the JLS (Java Language Specirication, 3rd ed):

3.9 Keywords
The following character sequences, formed from ASCII letters, are reserved for use as keywords and cannot be used as identifiers (�3.8)... While true and false might appear to be keywords, they are technically Boolean literals (�3.10.3). Similarly, while null might appear to be a keyword, it
is technically the null literal (�3.10.7).

... then

a literal is the source code representation of a value of a primitive type, the String type, or the null type.

You can read the JLS, especially chapter 3: Lexical Structure. I think it helps in understanding that.
Maduranga, yes, you can refer to the implemented methods of an interface as you wrote. You can also have access, through the dot notation, to the interface constants but of course you would not be authorized to change them. You can only access the interface methods and constants, no others. You can also (and it is preferable) access the constants directly through the interface name with the constant name, like

For some clarification: interfaces do not define constructors. Constructors belong to classes only.

Here is an example:

Finally, what is important to know here is

A method that is native is implemented in platform-dependent code

JLS 3rd edition, native Methods.

Even though the code of the method declaration looks abstract a native method is implemented!
When you declare a class, indicating that it implements one or more interfaces, you can assign an instance of it to a variable declared as any of the interfaces it implements.

So, you "computer" object can be viewed by other client code as a keyboard, or a cpu, and as a computer!!!

You can look at it as an instance of class implementing interfaces has the behavior of its interfaces.

Although I admit that the code you showed sounds illogical: a computer "is not" a keyboard, but it has a keyboard.

That code works, but it would be more logical to have something like:

In the book by Sierran and Bates, it is written (p.90) <b>Native Methods</b>... native can <i>never</i> be combined with abstract...

But, in the self test that follows the chapter, "private native void m1();" is shown as legal! I tested it, and it is true.

I know, the abstract keyword is not shown, but I thought that ending a method declaration with ";" after the "()" was indicating the compiler as abstract. If this is an abstract method declaration, why does the compiler not complain that it must be declared as abstract?
That exam includes Java 2 SE 5.0 features.
How much time does it take usually to Sun to change the exam requirements when a new "big" release of the language is done?


If you don't have any IDE for developing in Java, you may want to download "NetBeans IDE + J2SE SDK", else, if you want only the SDK, then I would suggest that you download " J2SE v 1.4.2_05 SDK includes the JVM technology". Both at .

For IDE I prefer Eclipse.
19 years ago
Forgot: if your intention is to run the loop 5 times, then you should use "i<5".