A class (implementing a generic interface) has a method which returns `java.lang.Object` datatype instead of the expected. Is it safe to typecast it at the caller statement?

```java
import java.io.*; 
import java.lang.*;

interface dataCharge<A>{
    public A change(A ele); 
}

class APCDcharge implements dataCharge<APCDcharge>{
    private String name;
    private Integer charge;
    public void setName(String name){
        this.name = name;
    }
    public void setCharge(Integer charge){
        this.charge = charge;
    }
    public String getName(){
        return name;
    }
    public Integer getCharge(){
        return charge;
    }
    public String getKey(){
        return name+":"+charge;
    }
    @Override
    public APCDcharge change(APCDcharge ele){
        APCDcharge newele = new APCDcharge();
        newele.setCharge(ele.getCharge()+100);
        newele.setName(ele.getName());
        return newele;
    }
}

public class Main {
    public static void main(String[] args) {
        APCDcharge c = new APCDcharge();
        c.setName("ABC");
        c.setCharge(100);
        APCDcharge d = timePass(c);
        System.out.println(d.getKey());
    }
    private static <T extends dataCharge> T timePass(T element){
        T res = element.change(element);
        return res;
    }
}

```

The above code snippet gives error :

`error: incompatible types: Object cannot be converted to T
 T res = element.change(element);`

I also tried typecasting `element.change(element)` with `T` datatype like : 

`T res = (T)element.change(element);`

And the code is compiling (with a warning: `Note: Main.java uses unchecked or unsafe operations.`), but executing correctly. Is that safe a way to remove the error? Is there any other way to correct it?