I cleared SCJP 6.0 with 81% on January 25, 2010 (putting this up after a long gap), not a really good score, but happy to get a “PASS” :). I did manage to do some 25 days of preparation (serious preparation), but my coding experience in Java helped me a lot- In understanding the basic concepts easily and giving more time to learn the less used concepts like Generics, Collections, Threading. Through out my preparation and after appearing for the exam there are few things I wanted to share with the aspirants:
SCJP
Working with Java Enumerated types (Enums)
In this post I would like to explain about Enums in Java. Though in my 2 years of coding in Java I have seldom used Enums but they do provide a lot of features when we are required to create a say limited instances of certain type. In this post I have made use of an example written out of inspiration from the example program given in “A Programmer’s Guide to Java SCJP certification” by Khalid A. Mughal and Rolf W. Rasmussen. The example is given in the Section Enumerated Types. I will be developing the Enum as we go through the article.
What is an Enumerated Type or Enum tpye? Enum Type defines a finite set of symbolic names and their values. Suppose we have to define 3 constants- LOW, MEDIUM and HIGH to denote the 3 speeds of Rotation. We can do it by declaring static final variables as follows-
class Speed{ public static final int LOW=1; public static final int MEDIUM=2; public static final int HIGH=3; }
Shadowing Variables in Java Demystified
One of the meanings of the word “Shadow” in the Oxford Dictionary is “a weak or less good version”. Shadowing in Java is also something similar. One can shadow a variable in several ways. I would try to describe the one most comman ways which would trip most of us i.e. “Hiding an instance variable by shadowing it with a local Variable”. What exactly is Shadowing in Java? Shadowing is nothing but redeclaring a variable that’s already been declared somewhere else. The effect of Shadowing is to hide the previously declared variable in such a way that it may look as though you’re using the hidden variable, but you’re actually using the shadowing variable (The Code Snippet below will make it more clear). This most of the times happens by accident and causes hard-to-find bugs.
javaBLACKbelt- building better developers
About JavaBlackBelt (WebSite)
JavaBlackBelt is a community for Java & open source skills assessment. It is dedicated to technical quizzes about Java related technologies. This is the place where Java developers have their technology knowledge and development abilities recognized. Everybody is welcome to take existing and build new exams.
Initialisation Blocks in Java
Topic: Initialisation Blocks in Java
Apart from methods and constructors, initialisation blocks are the places where operations within a class can be performed.
Initialisations blocks can be:
- Static
- Instance