What will this program print?
(Click the link below for the answer. The answer may surprise
even experienced programmers!)
| public interface Employee { int GetSalary(); void GiveRaise(int amount); }
public struct Clerk : Employee { private int salary;
public Clerk(int salary) { this.salary = salary; }
public int GetSalary() { return salary; }
public void GiveRaise(int amount) { salary += amount; } }
class Test { static void Main(string[] args) { Clerk c = new Clerk(1000); ((Employee)c).GiveRaise(50); System.Console.WriteLine(c.GetSalary()); } } |
Answer to Test 1
[Back to Index]
|