All Computer Science Resources
Example Questions
Example Question #1 : Class Design
What is the difference between extending and implementing?
Extend refers to a relation between a superclass and subclass. Implementing refers to an interface. You can implement only a single interface but you can implement multiple classes.
You can extend an interface and implement a subclass. Subclasses can be implemented as frequently as needed but you can only extend a single interface.
Extend refers to a relation between a superclass and subclass. Implementing refers to an interface. You can extend only a single class but you can implement multiple interfaces.
Extend refers to a relation between a superclass and subclass. Implementing refers to an interface. You can extend only a single class but you can implement multiple interfaces.
By default, all classes are extensions of the Object class and therefore are extending a single class. Due to that concept, implementation was made with the idea that notion of only being able to extend a single class. Thus they allow you to implement an infinite amount of classes.
Example Question #2 : Class Design
Describe the difference between overloading a method and overriding a method.
Overwriting is the same method name and different parameters. Overloading is rewriting the body of the definition.
Overloaded methods and overridden methods both take in the same methods but overridden methods return a different parameter.
Overloading is the same method name and different parameters. Overwriting is rewriting the body of the definition.
Overloading is the same method name, same parameters but the name of the parameter is different. Overwriting is calling the same method in the same class.
Overloading is the same method name and different parameters. Overwriting is rewriting the body of the definition.
When you override a method, you are completely replacing the functionality of the method by overshadowing the method in the parent child with the one in the child class.
Overloading a method just allows you to have the same method name to have multiple meanings or uses. An example is '+' operator. In languages like Java, you can use '+' to append strings, add doubles, or add integers.
Certified Tutor