Skip to content


Possible class names in Java

What would be the result of execution of the following code?

package com.imsavva;

public class Test {
    public static void main(String[] args) {
        System.out.println(new _成分$().getGreeting());

class _成分$ {
    public String getGreeting() {
        return "Hello";

If your answer is “Hello”, then you’re right!
You can use any characters from the Unicode charset, in any case, to name classes (as well as variables and methods), except some preserved words like “null”, “volatile”, “public”, etc.

However, it’s strongly recommended to stick with the Java code conventions. The rules related to the class names are on page 10.

First two reasons to use the code conventions to me are:

  • Readability – I would love to meet class names like “Eyjafjallajökull” from time to time. But, the rarer the better.
  • Convenience for programmers from different countries – imagine the situation when you have to work with the code where class names contain symbols that are missing on your keyboard? 🙈

Switch case and default

int i = 0;

switch (i) {
    case 1:
    case 2:

This snippet will compile and run without issues. It might be dubious whether it’s okay to put the “default” block at the first place, but you can place it anywhere. In this case, the result would be:


However there is a good practice to put the “default” block at the end of the switch statement. Or avoid using switch statements at all. 🙂

Variables and fields instantiation

package com.imsavva;

public class Test {
    private String testField;
    public static void main(String[] args) {
        String testVariable;

This code won’t compile because of line 4:

When we declare a local variable, it must be initialized before use. Class fields don’t have to be initialized. In case we didn’t specify any value, a default value will be used.

The following list represents default field values:

    private byte b;     // 0
    private short s;    // 0
    private int i;      // 0
    private long l;     // 0
    private float f;    // 0.0f
    private double d;   // 0.0
    private char c;     // '\u0000'
    private String str; // null

1Z0-808 Preparation notes

The process of studying Java Core. The picture was taken from

During the preparation time, I was making notes to remember little tricks that I didn’t know or forgot. Although I would never recommend using some of the pieces of code from the notes in production, they might be helpful for those who are preparing for the exam.

So, as I mentioned in this post, I will do my best to keep my New Year’s resolution and post the most useful notes in my blog. Along with the main topic I will try to explain why some of the code examples should never appear in your production code.

All the posts related to this topic will be marked with a tag 1Z0-808.

Passed the Oracle 1Z0-808 certification

Good news, everyone!

Even though this is the first blog in 2018, I’m still alive and I’m happy to say that I have passed the Oracle Certified Associate exam with 94% of correct answers (I still can’t believe it 😱).

It took about a month to prepare and I was spending all my free the time after work to read a book and write and test code examples.

While preparing, I have made more than a hundred of small notes, and I hope to find time and motivation in the next two months to post them here.

See you in 2019 🙂🎄