What is the productive programming cycle?
A reliable cycle is to understand the problem, plan an algorithm, implement it, test it, debug and improve it, and explain why it works.
Study Java Foundations and Program Design with 12 free online flashcards. Review key terms, definitions, and concepts with this interactive flashcard deck.
What is the productive programming cycle?
A reliable cycle is to understand the problem, plan an algorithm, implement it, test it, debug and improve it, and explain why it works.
Where does a Java application begin execution?
Execution begins in the `main` method: `public static void main(String[] args)` in a Java application.
How should a public Java class be named on disk?
Normally, a public class named `Greeting` must be saved in a file named `Greeting.java`.
What is the difference between declaration and assignment?
A declaration gives a variable its type and name; an assignment stores a value in it. For example, `int score;` declares, while `score = 95;` assigns.
Which Java types fit whole numbers, decimals, logic, characters, and text?
Use `int` for whole numbers, `double` for decimals, `boolean` for logical values, `char` for one character, and `String` for text.
What value does `8 + 4 * 2` produce?
`16`. Multiplication is evaluated before addition, so `4 * 2` is calculated before `8 + 8`.
How do integer division and remainder differ in Java?
With two `int` operands, `/` performs integer division and discards the fractional part; `%` returns the remainder. Thus, `7 / 2` is `3` and `7 % 2` is `1`.
What is `(int) 9.99`?
`9`. Casting `9.99` to `int` removes the fractional portion; it does not round the value.
What does `"Average: " + (5 + 10) / 2.0` produce?
`Average: 7.5`. Parentheses make Java add `5 + 10` before dividing by `2.0`, then concatenate the result with the label.
How do `print` and `println` differ?
`print` displays text without moving to a new line; `println` displays text and then moves to the next line.
Why can `nextInt()` followed by `nextLine()` be surprising?
`nextInt()` reads an integer token, while `nextLine()` reads the rest of the current line. After `nextInt()`, an extra `nextLine()` may be needed to consume the remaining line break.
What are the three stages of a basic Java program?
Read the data, process it with expressions and assignments, then display the result. This is the input–process–output pattern.