Find the error(s) in the following code. The method should have a Synthesizer object say, “Hello, here are the instructions to run the application.” This should happen when the user clicks the Instructions JButton. The speechSynthesizer variable references a Synthesizer object, which is declared as an instance variable.

```
1 private void instructionsJButtonActionPerformed( ActionEvent event )
2 {
3 speechSynthesizer.setSpeakingRate( 100.0f );
4 speechSynthesizer.speakPlainText(
5 "Hello, here are the instructions to run the application" );
6
7 } // end method instructionsJButtonActionPerformed
```


1) The Sythesizer object speechSynthesizer does not have a method called setSpeakingRate. To set the speakingRate property, you need to obtain the Synthesizer- Properties object by invoking the getSynthesizerProperties method of speechSynthesizer. Then invoke the setSpeakingRate method of SythesizerProperties to set the speakingRate property. 2) Method speakPlainText takes two arguments, not one. The correct code is:

```
1 private void instructionsJButtonActionPerformed( ActionEvent event )
2 {
3 // get synthesizer properties
4 SynthesizerProperties properties =
5 speechSynthesizer.getSynthesizerProperties();
6
7 properties.setSpeakingRate( 100.0f );
8
9 speechSynthesizer.speakPlainText( "Hello, here are " +
10 "the instructions to run the application", null );
11
12 } // end method instructionsJButtonActionPerformed
```

Computer Science & Information Technology

You might also like to view...

Select the correct statement regarding C++ I/O streams:

a. C++ provides only high-level I/O capabilities because it is a high-level programming language. b. High-level (formatted) I/O is best for large-volume transfers. c. Low-level I/O breaks information down into small, meaningful groups of related bytes. d. Programmers generally prefer high-level I/O to low-level I/O.

Computer Science & Information Technology

You can call a BindingSource’s ________ method to move to the first row of the result.

a. First b. MoveFirst c. FirstRow d. None of the above

Computer Science & Information Technology

Given that k is an integer array starting at location 2000, kPtr is a pointer to k and each integer is stored in 4 bytes of memory, what location does kPtr + 3 point to?

a. 2003 b. 2006 c. 2012 d. 2024

Computer Science & Information Technology

Which of the following is not a Java primitive type?

a. char b. byte c. real d. double

Computer Science & Information Technology