Discuss the differences between creating a new class, extending a class and implementing an interface; and when each would be appropriate.

*Creating a new class is simply creating a class with no extensions and no implementations. The signature is as followspublic class MyClass(){}*Extending a class is when you want to use the functionality of another class or classes. The extended class inherits all of the functionality of the previous class. An example of this when you create your own applet class and extend from java.applet.Applet. This gives you all of the functionality of the java.applet.Applet class. The signature would look like this public class MyClass extends MyBaseClass{} *Implementing an interface simply forces you to use the methods of the interface implemented. This gives you two advantages. This forces you to follow a standard(forces you to use certain methods) and in doing so gives you a channel for polymorphism. This isn’t the only way you can do polymorphism but this is one of the ways.public class Fish implements Animal{}

 

This Question is not yet answered!

 
 

Related Answered Questions

 

Related Open Questions