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 }
```
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" );
In Performance Monitor, counters are multiple occurrences of a given object
Indicate whether the statement is true or false
Briefly describe a wireless packet sniffer.
What will be an ideal response?
You use subscripts 1 through 10 to access the elements in a ten element array.
Answer the following statement true (T) or false (F)