Java Assignment

profilejpFlute
java.docx

Perform the following problems from Chapter 10:

· 1-3

· 13-14

· 36

  1.   The extends keyword applies to

a class inheriting from another class.

a variable.

a method.

an expression.

  2.   A Java class can inherit from two or more classes.

true

false

  3.   In Java, multiple inheritance is implemented using the concept of

an interface.

an abstract class.

a private class.

13.  What fields and methods are inherited by which class?

14.   What fields and methods are not inherited?

36.   Write a graphical application overriding the paint method of the JFrame class. Inside it, cast the Graphics object to a Graphics2D object and draw a dashed, rounded rectangle. The length of the dashes should be longer than the length of the spaces between dashes. Hint: Look up the Graphics2D, BasicStroke, and RoundRectangle2D.Double classes in the Java Class Library.

Perform the following problems from Chapter 11:

· 1-3

· 12

· 46

  1.   Why are exceptions useful?

They can replace selection statements, thus saving CPU time.

Exceptions enable programmers to attempt to recover from illegal situations and continue running the program.

  2.   Some methods that throw an exception require try and catch blocks, while some do not.

true

false

  3.   What keyword is found in the header of a method that could detect an error and generate an appropriate exception?

throw

throws

exception

exceptions

12.   Assuming the file words.txt holds the following data:

CS1 Java Illuminated

what is the output of this code sequence:

a.  if the file is found?

b.  if the file is not found?

img

img

46.   Write a program that reads a file and counts how many lines it contains.

img