Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Knowledge Discovery In Databases

Authors: Gregory Piatetsky-Shapiro, William Frawley

1st Edition

0262660709, 978-0262660709

More Books

Students also viewed these Databases questions