Problems


[Page 382 (continued)]

11.1

What is the answer to each of the following?

  • What is a field?

  • What is a constructor?

  • What does override mean?

  • How do you specify the parent class of the class you are declaring?

  • If you don't specify a parent class is there still a parent class?

  • How do you overload a constructor?

  • What is the difference between override and overload?

  • How do you create an array?

  • How do you access elements of an array?

  • How do you initialize the elements of an array?

  • What is a Javadoc comment?

  • Can objects of a different class (in a different file) directly access private fields?

  • Can objects of a different class (in a different file) directly access public fields?

  • What is an accessor method?

  • What is a modifier method?

  • What does encapsulate mean?

  • What does super.method() do?

  • What does super() do?

11.2

Which of these is the correct class definition for a Teacher class?

  • public CLASS Teacher

  • public class Teacher

  • public class TEACHER

  • public class Teacher []

  • public class Teacher extends Object, Person

11.3

Which of these correctly defines a field in a class?

  • private INT count;

  • public INT count;


  • [Page 383]
  • private int count = "HI";

  • private int count;

11.4

Which of these correctly defines a constructor in the class Student?

  • PUBLIC STUDENT ()

  • public STUDENT ()

  • PUBLIC student()

  • public void Student()

  • public Student()

11.5

What other methods do all classes inherit from the Object class?

11.6

Create a class CartoonPanel and create a constructor that takes an array of Picture objects and displays them from left to right like a cartoon in a newspaper. You can use the scale method to scale the pictures to fit. You can create a new picture to use to display the cartoon on.

11.7

Modify the Student class getAverage() method to drop the lowest grade when calculating the average. You will need to loop through the array and find the lowest grade.

11.8

What class does Turtle inherit from (in your bookClasses directory)? What class does Picture inherit from? What class does FileChooser inherit from? What class does World inherit from?

11.9

What methods did the class Turtle inherit from its parent class?

11.10

What methods did the class Picture inherit from its parent class?

11.11

How many constructors does the Turtle class have? How are they different?

11.12

How many constructors does the Picture class have? How are they different?

11.13

Add method comments for all the methods in the Student class.

11.14

Add another constructor for the Student class that takes a name and a number which is the number of grades this student will have. It should create the gradeArray based on the passed number of grades.

11.15

Add a picture field to the Student class and create constructors that take a Picture object as well. Also create accessors and modifier methods for the picture field. Add a show() method which will show the Picture object if it isn't null.

11.16

Write the definition for a class Car which has the manufacturer, model, year, and number of doors. An example car has a manufacturer of Toyota, a model of Camry, a year of 2000, and a number of doors of 4. Be sure to code all accessor and modifier methods.

11.17

Write the definition for a class Book which has a title, an author, an ISBN number, a price, and the year it was published. Be sure to code all accessor and modifier methods. You can use the information for this book as a test case.


[Page 384]
11.18

Write the definition for a class Address which has line1, line2, city, state, and zip code. Be sure to code all accessor and modifier methods. Create an Address object with your address information in it.

11.19

Write the definition for a class CreditCard which has a number, an expiration date, and a name. Be sure to code all accessor and modifier methods.

11.20

Write a main method in the Picture class to create a Picture object and show it.

11.21

Write a main method in the Sound class to create a Sound object and play it.

11.22

Write a method in the Turtle class that takes an array of Picture objects. Use the drop(Picture p) method in Turtle to drop pictures at different locations in a circle.

11.23

What is the output from this:

> Object obj = new Student("Susan Dorda"); > System.out.println(obj);


Can you explain why we get this result?

11.24

What is the output from this:

> Object obj = new ClassPeriod("Mary Engelhardt",3) > System.out.println(obj);


Can you explain why we get this result?



Introduction to Computing & Programming Algebra in Java(c) A Multimedia Approach
Introduction to Computing & Programming Algebra in Java(c) A Multimedia Approach
ISBN: N/A
EAN: N/A
Year: 2007
Pages: 191

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net