Play audio slide show -- Keyboard shortcut: 'x'  Back to slide -- Keyboard shortcut: 'u'  next        Play sound for this slide -- Keyboard shortcut: 'y'  RedefTry2.java - En let ændring af ovenstående som illustrerer at redefinerede variable bindes statisk.Lecture 7 - slide 35 : 41
Program 2

class A {
 protected int v = 5;

 protected void m(int p){
   v = p;
 }

}

class B extends A{

 protected int v = 6;

 protected void m(int p){
   v = p;
   super.m(p-3);
 }

 public String toString(){
   return("B: " + "this.v = " + this.v + ", super.v = " + super.v  );
 }

}


class RedefTry2 {

 public static void main (String[] args){

   A aB1 = new B();
   B aB2 = new B();
   System.out.println("Variablen v gennem A kvalificeret variabel: " + aB1.v);
   System.out.println("Variablen v gennem B kvalificeret variabel: " + aB2.v);

 }

}