Test your Java experience for free – JavaBlackBelt

Recently I’ve come across another very interesting social service – JavaBlackBelt. Basically it gathers programmers who use Java language and related frameworks and aspects (OO programming, JSP, Struts, JSF, EJB). There are even exams on C#, Ruby, JavaScript, and AJAX but some of them are still beta versions.

Of course I’ve taken a couple of exams and this is my …

What happens if concate String value and int?

Can you predict the output/result of the following code?

String s = "A String ";
s += 12345;

The answer is: “A String 12345“.

The reason for that is described in the desciption of String class in Java 2 Platform SE 5.0 API:

The Java language provides special support for the string concatenation operator ( + ),

Collection classes in Java

Collections are very important on SCJP exam. It’s useful to remember the following…



  • ordered (index)
  • duplicates allowed


  • fast iteration
  • fast random access; as of Java 1.4 implements RandomAccess interface
  • slower instertion and deletion


  • the same as ArrayList but its metods are synchronized (therefore slower)


  • elements are doubly linked to one another; linkage adds methods that allow

Assertions in Java

assert Expression1 : Expression2;
  • Expression1 is asserted to be true; otherwise AssertionError (that shouldn’t be handled) is thrown
  • Expression2 allows to produce some additional information
  • Expression2 MUST result in a value – it generates a String message
  • allow testing during the development and debugging
  • are disabled at runtime by default
  • can be enabled using -ea or -enableassertions flags and selectively

Threds: multiple call to run() method

You can call run() method of a thread many times. However, not a single new thread will be started. This way JVM will only execute the code from run() method. And this will not probably be what you tried to achieve.

Remember: to start a new thread, you need to call start() method, which among others, will execute run() method …

Java: main method declaration

It’s good to remember that there are a few ways of defining the main() method in Java 5:

public static void main(String[] args) {}


public static void main(String args[]) {}


public static void main(String... args) {}

Sometimes, we don’t care and remeber of basic stuff, which can result in worse score on the exam icon_smile-5323953