This doesn't make a lot of sense. If the type of myVar is not statically known, you will only be able to use it via reflection. In that case, just store it as an Object.
Are you trying to verify that classMethod() is returning the expected type? Or are you trying to cast the result to a specific type so that you can invoke specific methods on it? In other words, what are you going to do with myVar next? Invoke a method like myVar.myMethod()?
Here's an example of invoking a method on an object using reflection. Refer to the Class documentation for a more detailed explanation.
Object myVar = AnotherClass.classMethod(); /* Get the class object for "myVar" to access its members. */ Class<?> myClass = myVar.getClass(); /* Find the public, no-arg method "myMethod()". */ Method mth = myClass.getMethod("myMethod"); /* Invoke "myMethod()" on "myVar", and assign result to "r". */ Object r = mth.invoke(myVar);
AnotherClass.classMethod()into anObjectand not worry about the type.