John Mercier

java programming and scjp

  • Blog
  • Projects

SCJP Master Exam Notes

Posted on May 16, 2010 by John J Mercier

Filed under Programming | 0 Comments

I recently took a Master Exam from the Sierra and Bates SCJP book and got a 53%. While I was answering questions I noted any problem I had with a question. Today, I'm going through these notes and the exam report to see what needs work. Also, why not make a blog entry out of it? The following list are things I need to remember for the next exam.

HashMap.size() returns the number of key-value mappings in this map.

The rules for overriding equals() and hashCode()

must consistently return the same integer, provided no information used in equals() is modified

if two objects are equal using equals() then they must return the same hashCode()

if two objects are not equal using equals() then they can have the same hashCode(), or a different hashCode()

calling method((short)7) with method(short x) and method(short... x) in the class will always use method(short x) instead of method(short... x).

Is-A relationships always rely on polymorphism!

Comparator

an interface

override compare(T o1, T o2);

returns 0 if o1.equals(o2)

returns negative if o1 is less than o2

returns positive if o1 is greater than o2

Static variables are not serialized (not sure if I need to know this on the new version of SCJP)

Interfaces cannot have static methods. Interface methods cannot have a body so a static method doesn't make sense. Interface methods are alway public abstract. Interface variables are always public static and final.

What is the difference between high cohesion and loose coupling?

High cohesion is how strong a class's responsibilities are related and focused. For SCJP questions member variables and methods should be related. If a method doesn't interact with a member variable then it is probable not a cohesive method.

Loose coupling is how much information one class needs from another to perform methods. Loose coupling in SCJP would be one class using accessors rather than public member variables.

Encapsulation encourages loose coupling by not sharing member variables directly to other classes or subclasses. Instead public setters and getters are used.

Learn the different variations in generics. <T> input<T>(), <? extends T> <? super T>. All of that.

Can abstract come after a class name? No. I thought this was false but decided I should look it up.

Is TreeSet sorted? Yes according to my Java pocket guide, it is. I believe this means it must implement the comparable interface, or be constructed with a comparator.

Can an Integer constructor take "17" as a param? Yes. Darn, I think I got this one wrong on the exam.

What is the regex "." metacharacter? It matches with any single character. I'm guessing this means in the alphabet.

What does subMap() do? The subMap() method returns a NavigableMap that is linked to the original map. There are some catches.

  • Any new entries can be added to the original Map. new entries added to the submap must be within the range used to create the submap.
  • New entries added to the original map within the range of the submap are also added to the submap.
  • New entries added to the original map outside the range of the submap are not added to the submap.
  • New entries added to the submap are also added to the original map.
  • Using pollFirstXxx() on the original map will only remove from the submap if the entry polled is in the range of the submap.
  • Using pollFirstXxx() on the submap will remove the entry from the original map.
  • One other thing to remember is that the boolean values of headMap, tailMap, and subMap will include the arguments in the submaps.
  • Also, all of these ideas are the same for the Set collections.

Can TreeSet.ceiling() return the argument? Yes. from the javadoc "Returns the least element in this set greater than or equal to the given element, or null if there is no such element." So, if the argument is equal to an entry that entry will be returned.

How to get DateFormat with Locales? Use DateFormat.getDateInstance(DateFormat.LONG, Locale.FRANCE);

  • Also Only one DateFormat is needed to format many Date objects.

What are FileReader and BufferedReader classes? How are they different classes?

FileReader is an InputStreamReader which is a subclass of Reader. BufferedReader is a subclass of Reader as well. They both read characters from a source into a character array or CharBuffer. The major differences are FileReader reads only files, InputStreamReader can read any InputStream (ie file or network stream), and BufferedReader can Buffer any Reader using the Is-A and Has-A relationships similar to the InputStream and BufferedInputStream. I believe this is called the Decorator design pattern.

Share |

SCJP exam advice

Posted on April 29, 2010 by John J Mercier

Filed under Programming | 1 Comments

Recently, there have been a few good pointers posted at javaranch on what to expect on the exam here and here.

"Don't expect the exam center to be quiet. (going last on the day might help. I was the first one for the day and lot of people were coming in and going out in the middle of my exam.)"

I may have to call the exam center and ask about this. If it is busy in the morning it may be a good idea to take it later in the day.

"I wasn't able to review drag and drop question. The software was giving a warning that if I try to review the question then I'll have to re answer them which was really frustrating."

This is a huge deal, and I've seen a lot of complants about this on the forum. This should be fixed asap!

"Inner classes with most weirdest combination appears every where. You need to know the in and out of inner classes."

This is where I may have trouble... inner classes that extend inner classes anybody?

"Don't skip the tough questions thinking you can revisit them later because some of the questions appear easy, but it may not be that easy once you start thinking deeply!"

I think you could probably skip questions, but if you are skipping every other question maybe you should relax and just answer them. You can always mark the questions to look at later but at least put your best guess.

Share |

  • General (12)
  • Projects (3)
  • Programming (14)

Search

Tag Cloud

activism addthis.com data_structure downloading facebook google google-buzz introduction java javablackbelt jdbc johnmercier.com jsp linux model-1 netbeans nvidia objectivism official-english programming projects pti roller scjp server sql theme uncertainty velocity welfare-state

Friends

  • Ed
  • Shane

Links

  • Glazed Lists
  • JGoodies
  • Java Specialists
  • Swing 2.0
  • Swing Generics
  • ideone
  • pircbot

Feeds

  • All
  • /General
  • /Projects
  • /Programming
  • Comments

Referrers

  • direct (168)
  • www.playdota.com/for (38)
  • www.mycraft.com/ueba (37)
  • baccaratforums.com/g (37)
  • www.cooksillustrated (35)
  • znakomstvaca.info/si (10)
  • znakomonly.info/site (10)
  • microscopiclove.info (5)
  • microscopiclove.info (5)
  • microscopiclove.info (5)
  • znakomstvaca.info/si (5)
  • microscopiclove.info (5)
  • microscopiclove.info (5)
  • microscopiclove.info (5)
  • microscopiclove.info (5)
  • znakomstvaca.info/si (5)
  • microscopiclove.info (5)
  • microscopiclove.info (5)
  • microscopiclove.info (5)
  • microscopiclove.info (5)
  • microscopiclove.info (5)
  • microscopiclove.info (5)
  • znakomstvaca.info/si (5)
  • microscopiclove.info (5)
  • microscopiclove.info (5)
  • microscopiclove.info (5)
  • microscopiclove.info (5)
  • znakomstvaca.info/si (5)
  • microscopiclove.info (5)
  • microscopiclove.info (5)

Navigation

  • John Mercier
  • Weblog
  • Login

©2010 John J Mercier.

Designed by Free CSS Templates. Template by E. Strokin. Powered by Roller Weblogger 4.0.1.