At work we've been interviewing a few code monkeys at various levels. To gauge their knowledge I ask a few questions about C#, the programming language we use about 95% of the time. The questions vary and the 'pass' criteria varies with the salary requirements of the interviewee. One question I ask all potential employees is what does the 'virtual' keyword signify in C#. Knowing the answer to this question isn't make or break, but it's certainly an advantage.
Now for you non-code monkeys, virtual is an important part of polymorphism - which is a fancy phrase for objects that can pretend to be other objects. For example a cat may pretend to be a mammal or an organism. The virtual keyword is important in that it means you can 'override' functionality. For example for a cat you would override 'sound' with 'pur', while for dog you would override 'sound' with 'woof'. There's important technical ramifications going on behind the scenes, but ultimately it lets you override stuff further down the inheritance tree.
As you can imagine virtual is a critical part of class inheritance, something everyone interviewed claimed to understand. Now I am biased in that I absolutely love the C# language, it's evolved to become in my opinion, the most complete & versatile programming language available. For this reason I know a great deal about the language and I consider the 'virtual' keyword to be at best, intermediate knowledge if not basic. You shouldn't be messing with class hierarchies without knowledge of it - otherwise the class hierarchy could end up brittle and difficult to maintain pushing a programmer to use really bad constructs like new.
No one, regardless of salary requirements & experience (some are high) has been able to answer this question yet.
0 comments:
Post a Comment