Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Exam 7, Q19,Q30 Dan Chisholm

 
Dan Culache
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Question 30
Which of these classes declares the removeEldestEntry method?
Which of these classes declares the removeEldestEntry method?
a. LinkedHashSet
b. LinkedHashMap
c. LinkedList
d. TreeMap
e. TreeSet
f. HashMap
g. HashSet
h. Hashtable
i. None of the above

Question 19
class L{
public static void main (String[] args) {
StringBuffer s1 = new StringBuffer();
s1.ensureCapacity(16);
s1.append("ABCDEFG");
s1.setLength(5);
System.out.print(s1 + "," + s1.capacity());
}
}
What is the result of attempting to compile and run the program?
Are there questions that go into this level of implementation detail in the real exam?
 
Dan Chisholm
Ranch Hand
Posts: 1865
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The 1.4 version of the exam covers two new collections classes--LinkedHashMap and LinkedHashSet. One of the features that differentiates a LinkedHashMap from the older HashMap is the addition of the removeEldestEntry method. If you know that a LinkedHashMap is a good choice for the implementation of a cache then you would also know that LinkedHashMap declares a removeEldestEntry method.
The exam does not require memorization of the APIs for the collections classes. Instead, it requires you to select the best Collection implementation for a particular application. In this case, the removeEldestEntry method is the unique feature that makes the LinkedHashMap a good choice for use as a cache.
Having said the above, the real exam would be more likely to ask which class is the best choice for the implementation of a cache.
If Kathy or Bert reads this thread, then it would interesting to see if they would like to comment on how the real exam covers the two new collections classes.
 
Dan Chisholm
Ranch Hand
Posts: 1865
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The real exam does require familiarity with the methods of the String and StringBuffer classes. Furthermore, the real exam will contain trick questions in which an attempt is made to invoke a StringBuffer method on a String object.
 
Dan Culache
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, I've got it. I'll get into that as well.
Thanks Dan
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic