About Question com.enthuware.ets.scjp.v6.2.382 :

Help and support on OCA OCP Java Programmer Certification Questions
1Z0-808, 1Z0-809, 1Z0-815, 1Z0-816, 1Z0-817

Moderator: admin

Post Reply
Johnny

About Question com.enthuware.ets.scjp.v6.2.382 :

Post by Johnny »

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.

Pablo Reyes

Re: About Question com.enthuware.ets.scjp.v6.2.382 :

Post by Pablo Reyes »

Why should it? It's called hiding (http://www.xyzws.com/Javafaq/what-is-va ... adowing/15).

Post Reply

Who is online

Users browsing this forum: No registered users and 239 guests