• 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
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

Dan's new Collections Questions  RSS feed

 
Ranch Hand
Posts: 1865
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A just uploaded a beta version of New Collections Questions. Most of the new questions focus on the LinkedHashMap and LinkedHashSet classes.
Please let me know what you think of the new questions.
 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dan, I need ask you question?
You update all questions from all your deprecated exams, or all different exam ( question sets).
I bit confused. It may be silly. Assit me,.
Thanks in advance,
Agathian.T
 
Dan Chisholm
Ranch Hand
Posts: 1865
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The questions in the beta versions of the exam are new relative to the previous version. In this case, the previous version is September 27. At this time, there are two beta exams--one on threads and the other contains new questions on the collections topic.
Within the next week or two I will probably merge the beta exams into the rest of the exam. The new exam will contain all of the questions from the September 27 version plus the new questions from the beta exams along with a few other new questions.
The deprecated exams can be deleted at any time so I don't advise using them. I only leave them up so that people can complete whatever exam they might be working on before moving to the latest version of the exam.
Does the above answer your question?
 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does anyone know of a readable, plain-English treatment of the LinkedHashMap and LinkedHashSet classes available online?
 
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Dan,
Your mock exam is quit good, but would you tell me which exam is for scjp1.4? I can take more focus on them, thx.
 
Ranch Hand
Posts: 279
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Dan for your work,
So your beta exam about collection is more for the 1.4 or just adding more questions on collections? You know they will stress more on the collections topic in the 1.4 exam.
Also another question, why is always Serializable imported in your code, what's the relation with collections?
Thanks in advance for the reply
 
Dan Chisholm
Ranch Hand
Posts: 1865
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Eric Michael:
Does anyone know of a readable, plain-English treatment of the LinkedHashMap and LinkedHashSet classes available online?



The API Specification for the LinkedHashMap and
LinkedHashSet contain all the information that is needed to answer the questions that I uploaded today.
 
Dan Chisholm
Ranch Hand
Posts: 1865
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Kelvin Michael:
Hi Dan,
Your mock exam is quit good, but would you tell me which exam is for scjp1.4? I can take more focus on them, thx.


The LinkedHashSet and LinkedHashMap were introduced with Java 1.4. The previous
version of my Collections exam, September
27, did not contain the updates for 1.4.
The 1.4 version of the SCJP exam removes IO and AWT. Those topics were never in my exam so there is no section of my exam that you need avoid.
The Assertions exam is specifically for 1.4, so if you would like to focus on sections that are only applicable to 1.4 then the Assertions exam would be helpful.
 
Dan Chisholm
Ranch Hand
Posts: 1865
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Alfred Kemety:
Thanks Dan for your work,
So your beta exam about collection is more for the 1.4 or just adding more questions on collections? You know they will stress more on the collections topic in the 1.4 exam.
Also another question, why is always Serializable imported in your code, what's the relation with collections?
Thanks in advance for the reply


Yes, the new beta questions for collections focus mostly on the LinkedHashMap and LinkedHashSet classes that were introduced with Java 1.4. There are also a small number of other new collections questions that are not related to the 1.4 updates.
Thank you for mentioning the import statements. I'll go back and remove them. Serializable is always imported because the first questions that I did using the instanceof operator tested to see if the collections were Serializable and Cloneable. When I develop a new question I copy the block of XML that defines all of the elements of a an earlier question and I paste it at the bottom of the xml file. Then I paste in a new block of code that was tested in a java file and I change the answer options and the remark. The import statements are just artifacts of an earlier question. I hope they weren't too distracting.
 
Alfred Kemety
Ranch Hand
Posts: 279
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, it didn't distract me at all, but was just wondering....
So are all Collection implementations serializable and clonable?
 
Dan Chisholm
Ranch Hand
Posts: 1865
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The WeakHashMap is not Serializable and Cloneable, but all of the others are.
 
Ranch Hand
Posts: 2596
Android Firefox Browser Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have a look at ths article about LinkedHashMap and LinkedHashSet, it might be helpful.
http://www-106.ibm.com/developerworks/java/library/j-mer0821/
HTH,
- Manish
 
Cowgirl and Author
Posts: 1589
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Dan Chisholm:
The WeakHashMap is not Serializable and Cloneable, but all of the others are.


As far as the exam is concerned, you're good to go with that. But there are also a few 'hidden' collections that aren't necessarily serializable. For reasons none of us can figure out, the collection returned from getting "values" from a HashMap is not serializable, and boy has that killed a lot of my students in distributed programming classes.
You call the values() method on a HashMap when you want just the values to put in, say, an ArrayList. The values collection does indeed implement Collection, but AAACK not serializable. There are others lurking as well...
import java.util.*;
import java.io.*;
class TestCo {
public static void main (String [] args) {
HashMap hm = new HashMap();
hm.put("foo", "foof");
Collection c = hm.values();
if (c instanceof Serializable) {
System.out.println("true");
}
else {
System.out.println("false");
}
}
}
The output of this is "false" -- the collection implementation for the values of HashMap is not serializable.
You won't have to know that for the exam, but I just wanted to point out that you can't always guarantee that an implementation will be serializable until you test it, since the values collection for HashMap doesn't even have an accessible API -- I think its an inner class to HashMap.
cheers,
Kathy
 
Kathy Sierra
Cowgirl and Author
Posts: 1589
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Manish Hatwalne:
Have a look at ths article about LinkedHashMap and LinkedHashSet, it might be helpful.
http://www-106.ibm.com/developerworks/java/library/j-mer0821/


Everyone taking the 1.4 exam should read that article. It's quite relevant to the exam. Thanks Manish!
 
Dan Chisholm
Ranch Hand
Posts: 1865
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Kathy Sierra:
You call the values() method on a HashMap when you want just the values to put in, say, an ArrayList. The values collection does indeed implement Collection, but AAACK not serializable. There are others lurking as well...


Kathy,
Thank you for pointing that out. You sparked my curiosity so I took a quick look at the Hashtable source code. In case anyone is interested, I pasted the interesting members below in the code block.
The following is the description of the Hashtable.values method from the API Specification (Javadoc).

Returns a Collection view of the values contained in this Hashtable. The Collection is backed by the Hashtable, so changes to the Hashtable are reflected in the Collection, and vice-versa. The Collection supports element removal (which removes the corresponding entry from the Hashtable), but not element addition.


The following is the source code for Hashtable.values and the Hashtable.ValueCollection class.

The above is also a good example of how the AbstractCollection class can be useful when there is a need to return a special version of a Collection. The clear method contains a good example of using the qualified "this" statement to access a method of the enclosing Hashtable class.
 
The human mind is a dangerous plaything. This tiny ad is pretty safe:
how do I do my own kindle-like thing - without amazon
https://coderanch.com/t/711421/engineering/kindle-amazon
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!