a) Consider two C# classes, mobileRobot and grippingRobot, now we decide to create a third class
mobileGrabber that has the same actions as both our mobileRobot and grippingRobot classes.
Explain why C# (and some other languages) will not allow us let mobileGrabber inherit from both
mobileRobot and grippingRobot.
b) C# avoids this issue by allowing classes to inherit from multiple interfaces, explain why this
would solve the above problem if mobileRobot and grippingRobot were intefaces rather than
c) What are the rules concerning classes inheriting from interfaces with regard to the methods that
are declared in the interface ?
d) Supposing in the example in part a) mobileRobot is a class and grippingRobot is an interface. If
moveRobot is a method that belongs to mobileRobot and closeGripper is a method that belongs
to grippingRobot what would mobileGrabber have to do if it wanted to use these two methods
(assuming it inherited bot mobileRobot and closeGripper).
e) If mobileRobot had a method called switchOnRobot and we decided that the inherited class
needed to implement that method differently how could we do this ? Would we still be able to
inherit from the original class and how would we alter the method ? What is this called in Object
Oriented Programming ?
f) In terms of object oriented programming and C# describe the following :
i) What is a class constructor and what is its purpose ?
ii) What happens if a class does not have a constructor ?
iii) Under what circumstances may a class have more than one constructor ?
iv) If a class inherits from a superclass that has multiple constructors which constructors
does in inherit ? Explain why.
Page 3 of 9
g) Destructors are very rarely used in C# but are common in C++.
i) Explain what a destructor does.
ii) State why destructors are used more in C++ than C#.
iii) Give one example of when a programmer may use a destructor in C#.