Well the Object class of java is in the java.lang package and your class is in the default package that's why it compiles fine. There can be two classes with the same name in different packages. This is the whole point of packages, to avoid naming conflicts...