Mehul,
It's throwing that error because the
System.out.println( c2 ); statement is not inside a method or an initilization block... so
Java has no idea what you are talking about... the only thing that can be outside of a method or initialization block are attribute declarations ( plus optional assignment of that attribute ), and inner classes.
Also, if these classes are in one file together, only one of them should be declared
public, and that one should be the one that has the same name as your source code file. ( i.e. if you keep test as the public class call it test.java, if you keep pubClass as the public class call it pubClass.java )
HTH,
-Nate