Qual a saída e a explicação?
package br.com.Gernerics;
public class Base {
int x = 2;
int method(){
return x;
}
}
package br.com.Gernerics;
public class SubClass extends Base{
int x = 3;
int method(){
return x;
}
}
public class TestBaseSub {
public static void main(String[] args) {
Base b = new SubClass();
System.out.println(b.x);
System.out.println(b.method());
}
}
// A - Nothing. The code fails to compile because the object b is not created in a valid way.
// B - 2 and 3
// C - 2 and 2
// D - 3 and 3
// E - 3 and 2