SCJP Exam Preparation

Hi all,

I am preparing for the SCJP exam and started the preparation about 3 months back. Its been a very tough decision for me to kick-start the preparation but then after one of my friends made me realize that I am wasting my precious time and that it is important to get certified ASAP, I started the preparation. I am going to tell you about the journey till now (I have still not given the certification exam). In my company the certification is compulsory though and I need to get certified by the end March 2008. I guess there is enough time till then. But you never know. Sometimes people might take years to get certified. Ok what I am going to do is to update this post till I get certified regrading what decisions I made in my journey to get certified :-)

1. So let me tell you that I finished Kathie Sierra’s book “SCJP Sun Certified Programmer for Java 5 Study Guide (Exam 310-055) (known best book for the certification as far as I know). This book has got everything that you might need to clear the certification with good score. I have my friends her in the company most of who have scored more than 90%in the exam (one has has also scored 100% :-) ). So I finished this book first time in about 20 days of time. There are a total of 10 chapters.

2. Although I started taking the mock tests that are freely available on the Internet. I tried Enthuware and whizlabs tests. But I did not get the expected score (average 70%). The reason obviously being that I probably did not remember all the details properly that are there in the book. So today I decided to re-read the book and then probably will take the mock exams again. Let’s see what happens…….

3. I am glad to announce that today I am nearly going to complete the whole book. I have already read till the 9th chapter half way and hope o complete the book by end of next weak (I would have completed it this weekend itself but then I have some prior appointments, so won’t be able to make it.)

“Protected” and “Default” JAVA Access Modifiers

I guess that these two are the most confusing and misunderstood access modifiers amongst all other JAVA access modifiers for most of the average java programmers till date . I would like to take one by one. Lets start with “default first”

Default: Default access modifier is no-modifier. i.e when you do not specify any access modifier explicitly for a method, a variable or a class ( FYI : a top-level class can only be default or public access modifiers) it gets the default access. Default access also means “package-level” access. That means a default member can be accessed only inside the same package in which the member is declared.

Protected: Protected access modifier is the a little tricky and you can say is a superset of the default access modifier. Protected members are same as the default members as far as the access in the same package is concerned. The difference is that, the protected members are also accessible to the subclasses of the class in which the member is declared which are outside the package in which the parent class is present. But these protected members are “accessible outside the package only through inheritance“. i.e you can access a protected member of a class in its subclass present in some other package directly as if the member is present in the subclass itself. But that protected member will not be accessible in the subclass outside the package by using parent class’s reference. Confused with language ? Take an example. Say there is class “Super” in package A containing a protected integer variable “protected int x” and it’s subclass “Sub” in package B. The following would be a legal statement in a class B:

System.out.println(x); // valid

Whereas following would be an illegal statement:

System.out.println(new Super().x);

// invalid, as you cannot use parent class reference to access the protected member outside the package.

Once the child gets access to the parent class’s protected member, it becomes private (or rather I would say a special private member which can be inherited by the subclasses of the subclass) member of the subclass.

I hope that clarifies the difference between the private and default access modifiers. But if you have a question still about it, please leave a comment and I’ll get back to you. :-)

thx

Posted in Java. 11 Comments »