Blog

Output of following code:

abstract class Fruit {
public int color = 20;
public abstract Fruit getType();
}

class Apple : Fruit {
public int color = 21;
public override Fruit getType(){ return this;}
}

class RedApple : Apple {
public int color = 22;
public override Fruit getType(){ return this;}
}

class Program {
static void Main(string[] args) {
Fruit f = new RedApple();
Console.WriteLine(f.getType().color);
}
}