Question
3.8 Explain what accidental overloading is and the preferred Java method for preventing it. 3.9 If an overridden method in a subclass needs to call
3.8 Explain what accidental overloading is and the preferred Java method for preventing it.
3.9 If an overridden method in a subclass needs to call the overridden superclass method, how is this accomplished?
3.10 True or False? It is legal for a method in a class to overload another method also in the same class. Explain.
3.11 True or False? It is legal in a class for a method to override another method also in the same class. Explain.
3.12 True or False? It is legal in a subclass for a method to overload a method in the superclass. Explain.
3.13 True or False? It is legal in a subclass for a method to override a method in the superclass. Explain.
3.14 True or False? It is legal in a superclass for a method to overload a method in a subclass. Explain.
3.15 True or False? It is legal in a superclass for a method to override a method in a subclass. Explain.
3.16 In a subclass constructor, the superclass default constructor is called automatically before the statements of the subclass constructor begin executing. Suppose we wish to call a different superclass constructor (i.e., not the default constructor) from the subclass constructor. Explain how this is accomplished and give an example.
4 Objects, Classes, Polymorphism, and Interfaces
4.1 In the video lecture for Interfaces : Section 6 we discussed an example program that implements an inheritance hierarchy (Mammal is the superclass of Cat and Dog; Insect is the superclass of Cricket). Which method or methods in that program are called polymorphically?
4.2 Write the Java code to declare a new class Bee which is a subclass of Insect. The noise made by a Bee is "Buzz".
4.3 Write the Java code to declare a new abstract class Amphibian that implements the MakesNoise interface.
4.4 Write the Java code to declare a new class Frog which is a subclass of Amphibian. The noise made by a Frog is "Ribbet".
4.5 Modify the run() method of Main and add some Bees and Frogs to critters. Build your program and verify that it works correctly. Include all of your .java source code files in the zip archive that you submit for grading.
6 Nested Classes
6.1 Explain what an inner class is.
6.2 Explain how a local class differs from an inner class.
6.3 Explain how an anonymous class differs from an inner and local class.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started