Why is this program not polymorphic? [closed]

In public void A1(int a,int b){ c = this.a+this.b; } You are ignoring the parameters you are passing to your method, and add the instance variables this.a and this.b instead. Change it to public void A1(int a,int b){ c = a+b; } in order to add the two arguments.

Is Java "pass-by-reference" or "pass-by-value"?

Java is always pass-by-value. Unfortunately, when we deal with objects we are really dealing with object-handles called references which are passed-by-value as well. This terminology and semantics easily confuse many beginners. It goes like this: public static void main(String[] args) { Dog aDog = new Dog(“Max”); Dog oldDog = aDog; // we pass the object … Read more