Skip to content

Instantly share code, notes, and snippets.

@anirudhjoshi
Created November 1, 2012 01:50
Show Gist options
  • Save anirudhjoshi/3991115 to your computer and use it in GitHub Desktop.
Save anirudhjoshi/3991115 to your computer and use it in GitHub Desktop.
CircleTest2.java
public class CircleTest2 {
public static class Circle_1 {
public float r = 100;
public float getR(){ return r;}
}
public static class GraphicCircle_1 extends Circle_1 {
public float r = 10;
public float getR(){ return r;}
}
public static void main(String[] args){
GraphicCircle_1 gc = new GraphicCircle_1();
Circle_1 c = gc;
System.out.println("Radius = " + gc.r);
System.out.println("Radius = " + c.r);
System.out.println("Radius = " + gc.getR());
System.out.println("Radius = " + c.getR());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment