Preciso da ajuda de vocês, me respondam e expliquem a seguinte questão, pois não entendi direito:
What will happen when you attempt to compile and run the following code?
class HelSte{
String nat="dub";
public void jume(){
System.out.println("HelSte");
}
}
public class HarMol extends HelSte{
String nat="uk";
public static void main(String argv[]){
HarMol hm = new HarMol();
hm.go();
}
public void jume(){
System.out.println("HarMol");
}
public void go(){
HelSte hs = new HarMol();
hs.jume();
System.out.println(hs.nat);
}
}
Ele imprime " HarMol " seguido de "dub "
mas realmente não entendi porque imprime “dub” e não “uk”… alguém poderia me ajudar?