Showing posts with label Sun. Show all posts
Showing posts with label Sun. Show all posts

6 July 2009

Passed the SCJP - A reflection about the exam

It's finally done! I passed the SCJP last June and therefore I would like to reflect things I have learned and share my thoughts with you.

Study material
For the SCJP exam preparation I used the web learning lessons provied by SUN and SCJP Java 6 Study Guide. The web learning lessons and espessially the example exams where really valuable to me . They give you the feeling how hard the exam can be and what kind of questions could be asked.

To all future students: Repeat the test exams as much as you can. This will get you through the SCJP exam.

The 'SCJP Java 6 Study Guide' introduces all SCJP topics very well and contains a CD-ROM with additional test exams. These test exams are definitely harder than those of SUN but I really recommend to take these test exams. If you pass these test exams you will definitely pass the real SCJP exam!

Exam day
I took the exam at test-site in Zurich downtown. First of all I had to identify myself with two different identifcation documents (e.g. passport, creditcard or drivers licence). After that I had to hand out my watch, wallet and my bag to the supervisor. All the thing were looked in a safe. Done! After that my supervisor introduced me to my exam workstation and told me that several cameras are observing me during the exam. Well therefore try NOT to cheat during the whole exam. It not worth it.

Next steps
Currently I am thinking about further steps within the SUN Certification Programm. One step could be the 'SUN Certified Java Developer', a very generell continuation of the SCJP based on developing a client/server desktop application using Swing. Another step could be the 'SUN Certified Web Component Developer'.

I have not yet decided what certification is going to be next but I am tending to the SCJD because may knowledge about SWING is quiet poor :(

27 May 2009

SCJP - Now it gets strange

Which two about using the java.io.Serializable class are true? (Choose two.)

A) If Dog extends Animal, then Animal must implement java.io.Serializable in order to serialize an instance of Dog.
B) If Dog has-a Collar, then Collar must implement java.io.Serializable in order to serialize an instance of Dog.
C) If Dog extends Animal and Animal implements java.io.Serializable but Dog does NOT implement java.io.Serializable, you can serialize an instance of Dog.
D) When an instance of a subclass is deserialized, none of the constructors in it's constructor chain will ever be invoked.
E) If you mark a class's instance variable volatile, and then serialize an instance of that class, the state of the volatile variable will be lost during serialization.

Sun's says: Options B and C are correct. A class's superclasses don't have to implement Serializable in order to be serialized, and if a superclass doesn't implement Serializable then it's constructor will run during deserialization. A transient variable's state is lost during serialization, but a volatile variable's state is not lost.
I really do agree with option C but cannot understand why option B should be absolutely right. I still can serialize the Dog instance even if the included Collar does not implement Serializable. I could mark the Collar instance variable transient and everyone would be happy at runtime.

SCJP - This one could knock me out

Can anyone solve this? I've chosen wrong :( And probably learned something.



1. class Test4 {
2. public static void main(String [] args) {
3. boolean x = true;
4. boolean y = false;
5. short z = 42;
6.
7. if((z++ == 42) && (y = true)) z++;
8. if((x = false) || (++z == 45)) z++;
9.
10. System.out.println("z = " + z);
11. }
12. }


What is the result?

A) z = 42
B) z = 44
C) z = 45
D) z = 46
E) Compilation fails.
F) An exception is thrown at runtime.

Becoming a Sun certified Java programmer or how to become a compiler

The next two weeks I am trying to prepare myself to Sun's certified Java programmer (SCJP) exam. Up to now it really does not kick ass. Well my main troubles with the studies are currently some topics in the exam objective 3.5 (Tokenizing).

Objective 3.5 - Tokenizing with Pattern and Matcher
Let's say there's the pattern 'a?' and we would like to tokenize the following string 'aba' using the following Java class.

public static void main(String[] args) {
Pattern p = Pattern.compile("a?"); // compile the pattern
Matcher m = p.matcher("aba");

while (m.find()) {
System.out.println(m.start() + " >" + m.group() + "<");
}
}

What I expected out of this listing was something like this.
0 >a< 
2 >a< 
But what it actually returns was this.
0 >a< 
1 >< 
2 >a< 
3 >< 
Mhm. According to my study book (from which I took this example) they talking about some zero-length matches when using the greedy quantifiers '*' or '?'. They say that zero-length matches can appear under the following circumstances.
  • After the last character of source data
  • In between characters after a match has been found
  • At the beginning of source data (if the first character is not a match. Try tokenizing this string '2aba')
  • At the beginning of zero-length source data
Well this rules seems to be regular expression specific and does not have anything to do with the Java implementation. The only funny thing is - I use RegEx Buddy to develop my regexes - that I cannot reproduce it in my favourite regex editor. Yet another topic to learn by rote (means not really understanding it but memorize it for the exams purpose only)