Find the error(s) in the following code. The following method should create a new Shape object with numberSides sides. Assume the Shape class is from Exercise 18.14.

```
1 private void manipulateShape( int numberSides )
2 {
3 Shape shape = new Shape( 3 );
4
5 shape.sides = numberSides;
6 }
```


The instance variable sides of class Shape is private so its value cannot be set directly as line 5 attempts to do. Line 5 should be changed to shape.setSides( number- Sides ); to properly set the value of sides.
```
1 private void manipulateShape( int numberSides )
2 {
3 Shape shape = new Shape( 3 );
4
5 shape.setSides( numberSides );
6 }
```

Computer Science & Information Technology

You might also like to view...

Which of the following statement displays Hello World?

a. System.out.printf( "%2s", "Hello " "World" ); b. System.out.printf( "%s %s", "Hello", "World" ); c. System.out.printf( "%s%s", "Hello, World" ); d. System.out.printf( "s% s%", "Hello", "World" );

Computer Science & Information Technology

In Performance Monitor, counters are multiple occurrences of a given object

Indicate whether the statement is true or false

Computer Science & Information Technology

Briefly describe a wireless packet sniffer.

What will be an ideal response?

Computer Science & Information Technology

You use subscripts 1 through 10 to access the elements in a ten element array.

Answer the following statement true (T) or false (F)

Computer Science & Information Technology