interwanderer Posted July 10, 2005 Posted July 10, 2005 Hello, I am studying for a microsoft exam vb.net. I have learned you use implements with interfaces and inherits with classes. but i have a series of questions that has a strange answer. here is the question with a strange answer. you use visual studio.net to develop an application for a department. the following interfaces exist. public interface IEmployee property salary() as double end interface public interface IExecutive INHERITS IEployee property AnnualBonus() as double End interface the IEployee interface represents a generic employee concept. all actual employees in your company should be represented by interfaces that are derived from IEmployee. Now you need to create a class named Managed to represent executives in your company. You want to create this class by using the minimum amount of code. how do you do this? (this is the answer but i don't understand it. It should be implements instead of inherits because it is an interface!!) public Class Manager inherits IExecutive end class (Can someone please explain to me why this is the answer and not implements IExecutive??????) thx Quote
Joe Mamma Posted July 10, 2005 Posted July 10, 2005 public Class Manager inherits IExecutive end class thxlooks like a misprint to me, but I could be wrong. . . one of the great things that makes c# better is no keyword for inheritance/implementation. . . public class Manager: Employee, IExecutive{} in vb reads public Class Manager inherits Employee implements IExecutive end class so much typing. why doesn't the compiler know that IExecutive is an interface and Employee is a class? and since it folows the class declaration it must be inheriting and implementing???? Not very smart, is it? Quote Joe Mamma Amendment 4: The right of the people to be secure in their persons, houses, papers, and effects, against unreasonable searches and seizures, shall not be violated, and no warrants shall issue, but upon probable cause, supported by oath or affirmation, and particularly describing the place to be searched, and the persons or things to be seized. Amendment 9: The enumeration in the Constitution, of certain rights, shall not be construed to deny or disparage others retained by the people.
Administrators PlausiblyDamp Posted July 10, 2005 Administrators Posted July 10, 2005 The issue is probably not to do with the compiler but for the readability of the code - some people prefer a more explicit syntax others a more terse syntax - if it wasn't for the convention of prefixing I before interfaces (despite the fact hungarian naming has been removed from everywhere else in the framework) how would you know that Employee was a class and Executive an interface? Both could be interfaces... At the end of the people can choose the language that suits them and still get the same end results - nobody is forcing people to work with a language they do not like. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
bri189a Posted July 11, 2005 Posted July 11, 2005 I'd say it's probably a misprint too. In actuallity I'd say Employee should be class and Executive a derived class since it IS an employee. But every design has it's own considerations. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.