One way of doing it is via identifying the exceptions (more or less a hit & trial method):
If using 1.x API's in client & connecting to 2.x Hadoop Cluster or vicecersa, by:
final String uri = "hdfs://remoteHostName:9000/user/myusername";
final FileSystem fs = FileSystem.get (URI.create (uri), conf);
Then we get the following exception
Exception in thread "main" org.apache.hadoop.ipc.RemoteException: Server IPC version 9 cannot communicate with client version 4
The above exception identifies that the client API & Remote Hadoop Cluster are not compatible but unable to get a absolute method to identify the version of remote Hadoop Cluster.