Home > Java > javaTutorial > body text

Chapter 3 Test

王林
Release: 2024-07-17 12:23:18
Original
1020 people have browsed it

(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!

source:dev.to
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!