It would be something like :
public class Whatever {
public int mymethod(int one, int two) { return 0; }
public int myothermethod(int one, int two, int three) { return 0; }
}
public class However extends Whatever
{
@Override // optional annotation
public int mymethod(int one, int two)
{
int answer = one * two;
return answer + 3;
}
}
But then you could instanciate Whatever
. To prevent instanciation of Whatever, either mark it as a abstract
or make an interface
out of it. It all depends how you want your classes to inherit Whatever
. Since there cannot be multiple inheritance, choose wisely.
public interface Whatever {
public int mymethod(int one, int two);
public int myothermethod(int one, int two, int three);
}
public class However implements Whatever
{
public int mymethod(int one, int two)
{
int answer = one * two;
return answer + 3;
}
public int myothermethod(int one, int two, int three) {
return 0;
}
}
or
public abstract class Whatever {
public abstract int mymethod(int one, int two);
public abstract int myothermethod(int one, int two, int three);
}
public class However extends Whatever
{
public int mymethod(int one, int two)
{
int answer = one * two;
return answer + 3;
}
public int myothermethod(int one, int two, int three) {
return 0;
}
}
** EDIT **
After some enlightenment from the comments, your C++ to Java equivalent is actually the third construct since you're using virtual
class methods on your C++ code.