Java Reference
In-Depth Information
8.
The
java.lang.Cloneable
interface is a
marker interface
. An object of the class that
implements the
Cloneable
interface is cloneable.
9.
A class can extend only one superclass but can implement one or more interfaces.
10.
An interface can extend one or more interfaces.
Q
UIZ
P
ROGRAMMING
E
XERCISES
Sections 13.2-13.3
**13.1
(
Triangle class
) Design a new
Triangle
class that extends the abstract
GeometricObject
class. Draw the UML diagram for the classes
Triangle
and
GeometricObject
and then implement the
Triangle
class. Write a test
program that prompts the user to enter three sides of the triangle, a color, and a
Boolean value to indicate whether the triangle is filled. The program should create
a
Triangle
object with these sides and set the color and filled properties using
the input. The program should display the area, perimeter, color, and true or false
to indicate whether it is filled or not.
*13.2
(
Shuffle ArrayList
) Write the following method that shuffles an
ArrayList
of
numbers:
public static void
shuffle(ArrayList<Number> list)
*13.3
(
Sort ArrayList
) Write the following method that sorts an
ArrayList
of numbers.
public static void
sort(ArrayList<Number> list)
**13.4
(
Display calendars
) Rewrite the
PrintCalendar
class in Listing 6.12 to display
a calendar for a specified month using the
Calendar
and
GregorianCalendar
classes. Your program receives the month and year from the command line. For
example:
java Exercise13_04 5 2016
This displays the calendar shown in Figure 13.9.
F
IGURE
13.9
The program displays a calendar for May 2016.
Search WWH ::
Custom Search