Q: How to apply polymorphism to xml deserialization? I have two types of xml:
<exec><cmd>STATISTIC</cmd><param></param></exec>

<exec><cmd>FILE_TO_CLIENT</cmd><param><filePath>"/opt/tst"</filePath><msg>"ls- la"</msg></param></exec>

I need to pass them to function that  might return two types of class object
class Statistic    {
}

class FileToClient
{
  String msg;
  String filePath;
}

In case the message is of type statistic - no fields are required. In case it is file_to_client , msg and filePath fields should be filled from xml.
How should I organize my class hierarchy so that the deserializer function could return both type of objects?

A: First of all.... Classes in java ALWAYS starts with UPPERCASE.
Second your question is not clear, but I will try to explain basic inheritance.

If you want both classes being same type to be returned by same method you need to have a common Parent class. All classes in Java inherits from Object class, but better if you define your own parent like this:
// parent class common to others
class YourParent {
    // put here any common attributes for child classes
}

Then make your child classes extend from parent:
class Statistic extends YourParent 
{
}

class FileToClient extends YourParent 
{
String msg;
String filePath;

}

Finally, you can use both FileToClient and Statistics as YourParent classes. 
For example, as return type in a method:
public YourParent doSomething() {
    if (something)
        FileToClient f = //
        return f;  // valid
    } else {
        Statistic s = //
        return s;  // valid also!!!
    }
}

