If the User says “age”, it has to be the “MyFirstClass”. So in this case, I could never use methods of “MyFirstClass”, it would be always “MySecondClass”.
There are many ways and the choice depend on your particular requirements, which we obviously don’t know.
For instance, you can let your classes to implement an interface with a single method (doSomething()) and declare the parameter with the type of the interface. The compiler will ensure that the method must be called with a class implementing the interface and the polymorphic call will run doSomething() method of the concrete class.
This is nothing specific to Dynamics AX - these are basics of object-oriented programming.