Problems


[Page 72]

3.1

Some computer science concept questions:

  • What is a file?

  • What is an operating system?

  • What does a compile do?

  • What does method visibility mean?

  • What is a classpath?

  • What is a wrapper class?

  • What is a hard disk?

  • What is a method?

  • What creates new objects?

  • What does "pass by value" mean?

  • What is a primitive variable?

  • What is an object variable?

3.2

Test your understanding of Java with the following:

  • What does pictureObj.show() do?

  • What does soundObj.play() do?

  • What does FileChooser.pickAFile() do?

  • What does turtle1.turnLeft() do?

3.3

Test your understanding of Java with the following:

  • What does turtle1.forward() do?

  • What does turtle1.turn(-45) do?

  • What does turtle1.turn(45) do?

  • What does turtle1.penUp() do?

  • What does turtle1.hide() do?

3.4

How do you create new objects in Java? How do you create a World object? How do you create a Turtle object?

3.5

Which of the following are class methods and which are object methods? How can you tell which are which?

  • Math.abs(-3);

  • soundObj.play();

  • FileChooser.pickAFile();

  • pictureObj.show();

  • ColorChooser.pickAColor();

  • turtle1.turnLeft();

3.6

What does this do? System.out.println(new Picture());


[Page 73]
3.7

How many and what kind of variables (primitive or object) are created in the code below?

> String fileName = FileChooser.pickAFile(); > Picture p1 = new Picture(fileName); > p1.show();


3.8

How many and what kind of variables (primitive or object) are created in the code below?

> World worldObj = new World(); > Turtle turtle1 = new Turtle(worldObj); > turtle1.forward(30); > Turtle turtle2 = new Turtle(worldObj); > turtle2.turnRight(); > turtle2.forward(30);


3.9

How many and what kind of variables (primitive or object) are created in the code below?

> double cost = 19.20; > double percentOff = 0.4; > double salePrice = cost * (1.0 - percentOff);


3.10

We evaluated the expression FileChooser.pickAFile() when we wanted to invoke the method named pickAFile(). But what does this do? Open the FileChooser class and find the method declaration.

3.11

Write a method for Turtle to draw a rectangle. Pass in the width and height for the rectangle.

3.12

Write a method for Turtle to draw a hexagon. Pass in the length of the sides.

3.13

Write a method for Turtle to draw a pentagon. Pass in the length of the sides.

3.14

Write a method for Turtle to draw an equilateral triangle. Pass in the length of the sides.

3.15

Create a World object and a Turtle object and use the Turtle object to draw a star.

3.16

Create a World object and a Turtle object and use the Turtle object to draw an arrow.

3.17

Create a World object and a Turtle object and use the Turtle object to draw a pyramid.

3.18

Create a World object and a Turtle object and use the Turtle object to draw a flower.

3.19

Create a World object and a Turtle object and use the Turtle object to draw a house.

3.20

Create a World object and a Turtle object and use the Turtle object to draw your first name.



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