1 Objects, Classes, Polymorphism, and Interfaces 4.1 In the video lecture for In
ID: 3847151 • Letter: 1
Question
1 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.
2 GUI Programming
5.1 For these exercises, include your completed .java files in the zip archive that you submit for grading. Complete the code in the provided View class to implement this GUI interface for a calculator. The calculator does not have to be fully functional; the primary objective of the assignment is to implement the GUI.
5.2 Complete the code in actionPerformed() so when the Exit button is clicked, the application will terminate.
5.3 Complete the code in actionPerformed() so when the About button is clicked, the application will display this about dialog:
3 .
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.
Kalkutron-9000 Kalkutron-9000 8 9 x y log 10 log e sqrt Clear About ExitExplanation / Answer
2)
Let's suppose we have an Insect class. This class contains two methods: 1) move() and 2)attack().
Now you want to define a Bee class, which is a type of Insect, but have different implementations of attack() and move(). This can be done by using an inheritance design like the following:
3)
/Main Class/
}
Here interface implements in this class.Basically interface inheritances two or more class but here both different class in same method use then both method which way implement in one class. Please check error correct code.
4)
5)Local class:
Inner class:
class Insect { private int size; private String color; public Insect(int size, String color) { this.size = size; this.color = color; } public int getSize() { return size; } public void setSize(int size) { this.size = size; } public String getColor() { return color; } public void setColor(String color) { this.color = color; } public void move() { System.out.println("Move"); } public void attack() { move(); //assuming an insect needs to move before attacking System.out.println("Attack"); } } Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.