Q:

Is it possible to use getters/setters of extended class in Java

I have the following
public abstract class MyData
{
      private String sID;
      public void setsID(String sID) {
        this.sID= sID;
    }
       public String getsID() {
        return sID;
    }
} 

This base class is being extended by 2 other classes 
public class DataTypeOne extends MyData
{
       private String sName;
       public void setsName(String sName) {
        this.sName= sName;
        }
           public String getsName() {
            return sName;
        }
}

public class DataTypeTwo extends MyData
{
       private String sSummary;
       public void setsSummary(String sSummary) {
        this.sSummary= sSummary;
        }
           public String getsSummary() {
            return sSummary;
        }
}

I am initializing this class as follows
MyData oDataOne = new DataTypeOne();
MyData oDataTwo = new DataTypeTwo();

Reason for that is that I have a factory method which shall give me the class based on type (One or two)
With oDataOne & oDataTwo, I am able to access getsID() from the base class but not the getters & setters of the respective class.
How can I access those? I

A:

You can't access a method that doesn't exist. All you've promised your Java compiler is that oDataOne and oDataTwo are MyData objects. Since the MyData class doesn't have the implementation-specific methods, you cannot ask Java to call those methods (since it doesn't think they exist).
If you want to access those methods, you need to either cast the object to a class that actually has the right methods, or you can add abstract method stubs to your base class, which will tell Java that those methods actually exist.
Type casting is simpler to write in the short term, but less clear, and you may run into more trouble down the road:
((DataTypeOne) oDataOne).getsName();
((DataTypeTwo) oDataOne).getsSummary(); // Throws ClassCastException!

Adding abstract stubs is more robust, but may not make sense if not all concrete subclasses should implement all abstract methods:
public abstract class MyData {
    public abstract void setsName(String name);
    public abstract String getsName();
    public abstract void setsSummary(String summary);
    public abstract String getsSummary();
}
public class DataTypeOne extends MyData {
    public String getsName() {
        // implement
    }
    public void setsName(String name) {
        // implement
    }

    // Still have to implement these!!!
    public String getsSummary() {
        // raise an exception or something if appropriate
    }
    public void setsSummary(String summary) {
        // raise an exception or something if appropriate
    }
}
// Same for DataTypeTwo

