Java is driven by some basic conventions, including that directory structure follows package structure, and java files are named after the classes they define.
You should have defined fileA as a class inside of fileA.java like so:
public class fileA {
public static void main(String[] args) {
Pair p = new Pair(0, 1);
System.out.println("a is "+p.a+" and b is "+p.b);
}
}
and a corresponding Pair class:
public class Pair {
public final int a;
public final int b;
public Pair(int a, int b) {
this.a = a;
this.b = b;
}
}
If you are calling javac from within the same directory as both java files, you should not declare a package at the top, as they are within the 'default package'. As such, the above should work.
Using the default package provides some convenience but also some restrictions which I won't elaborate on, but now that you know about the default package you can look it up. I recommend using package names, which is as simple as adding, as you did, something like:
package kugathasan;
at the beginning of each file. If you do this though, you should put both files in a directory called kugathasan and call javac from the directory containing kugathasan.