Home >Java >javaTutorial >Chapter 3 Test

Chapter 3 Test

王林
王林Original
2024-07-17 12:23:181099browse

(answers on page 607 - 627 of the pdf)

  1. Write a program that reads characters from the keyboard until a dot is received. Have him count the number of spaces. Report the total at the end of the program.

  2. Show the general form of the if-else-if ladder.

  3. Given the code below, what if is the last else associated with?
    Image description

  4. Show the for statement of a loop that counts from 1000 to 0 in intervals of -2.

  5. Is the following fragment valid?
    Image description

  6. Explain what break does. Be sure to explain its two forms.

  7. In the following fragment, after the break statement is executed, what is displayed?

Image description

  1. What does the fragment below display?
    Image description

  2. The iteration expression of a for loop does not always need to change the loop control variable according to a fixed value. Instead, the control variable can change in some arbitrary way. Using this concept, write a program that uses a for loop to generate and display the progression 1, 2, 4, 8, 16, 32,
    and so on.

  3. ASCII lowercase letters are separated from uppercase letters by an interval equal to 32. Therefore, to convert a lowercase letter into uppercase, we have to subtract 32 from it. Use this information to write a program that reads characters from the keyboard. It should convert all lowercase letters to uppercase and all uppercase letters to lowercase, displaying the result. Don't
    changes to any other characters. The program will terminate when the user enters a point. In the end, it should display how many changes occurred in the letter box.

  4. What is an infinite loop?

  5. When using break with a label, must it be in a block that contains break?

The above is the detailed content of Chapter 3 Test. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn