public interface Automobile { String describe(); }
class FourWheeler implements Automobile
{
String name;
public String describe(){ return " 4 Wheeler " + name; }
}
class TwoWheeler extends FourWheeler
{
String name;
public String describe(){ return " 2 Wheeler " + name; }
}
---
When TwoWheeler inherits name variable from FourWheeler, why compiler doesn't complain about attempt of defining variable with same name? Thanks in advance.
About Question com.enthuware.ets.scjp.v6.2.382 :
Moderator: admin
Re: About Question com.enthuware.ets.scjp.v6.2.382 :
Why should it? It's called hiding (http://www.xyzws.com/Javafaq/what-is-va ... adowing/15).
Who is online
Users browsing this forum: No registered users and 239 guests