Introduction to OOP Chapter 16: Overriding : next previous audio real text

Overriding versus Shadowing

It is common in programming languages for one declaration of a variable to shadow a previous variable of the same name:
class Silly {
	private int x; // an instance variable named x

	public void example (int x) { // x shadows instance variable
		int a = x+1;
		while (a > 3) {
			int x = 1; // local variable shadows parameter
			a = a - x;
		}
	}
}
Shadowing can be resolved at compile time, does not require any run-time search.
Intro OOP, Chapter 16, Slide 18