Following is a part of my code for a project:
public class Body extends Point{
public double x, y, mass;
public Body() {
x = y = mass = 0;
Yes, you'll have two variables, with one hiding the other. It makes sense to allow it for two reasons:
Base and a derived class Derived which the author of Base has no idea about. Should the author of Base never be able to add any fields, just because a derived class might share the fields? Or should Derived stop compiling when the change to Base doesn't actually affect the correctness?