Find the error(s) in the following code. The following method should create a new Shape object with numberSides sides.

```
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.

Computer Science & Information Technology

You might also like to view...

The String method substring returns ________.

a. a char b. a String c. void d. a char[]

Computer Science & Information Technology

The principals of object oriented programming include:

(a) encapsulation (b) inheritance (c) polymorphism (d) all of the above

Computer Science & Information Technology

Windows Vista requires some ________ to operate properly and perform its own system functions

Fill in the blank(s) with correct word

Computer Science & Information Technology

The Increase Font Size button is on the ________ tab

A) Design B) Home C) Insert D) Format

Computer Science & Information Technology