Question: Java !! Please help 1. Declare (write) a Java interface with two methods, one that adds two doubles together returning the sum and one that
Java !! Please help
1. Declare (write) a Java interface with two methods, one that adds two doubles together returning the sum and one that multiplies two doubles together returning the product. Use descriptive identifiers. Include JavaDoc comments.
| 2. The iterator is the preferred mechanism to access the elements in a linked list. (See below for a quick summary of SimpleLinkedList.) Write the code for the interface java.util.Iterator, version1.7, that is, with three methods. You may ignore writing JavaDoc comments. public class SimpleLinkedList implements java.util.List { private Link first; private Link last; private int numElems; ... } class Link { Object item; Link next; ... } 3.
|
| One of your colleagues is trying to create a component that draws concentric circles. Heres the code so far: import java.awt.*; import javax.swing.*; public class BullsEye extends JPanel { private static void draw(Color c, int x, int y, int r, Graphics g) { g.setColor(c); g.drawOval(x r, y r, 2*r, 2*r); repaint(); } public void paintComponent(Graphics g) { int x = getWidth() / 2; int y = getHeight() / 2; draw(Color.green, x, y, 50, g); draw(Color.red, x, y, 100, g); draw(Color.blue, x, y, 150, g); } } 10. This code doesn't work. What is the problem? 11. What is the effect of the following declaration? import java.awt.*; |
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
