Summary

These flashcards cover programming concepts, including code examples, and multiple-choice questions. Topics include Java programming, object-oriented programming principles, and GUI elements.

Full Transcript

Quizlet-style Flashcards Page 1: 1. What is the equivalent code for `if (gender == 1) { if (age >= 65) { ++seniorFemales; } }`? a. `if (gender == 1 || age >= 65) { ++seniorFemales; }` b. `if (gender == 1 && age >= 65) { ++seniorFemales; }` c. `if (gender == 1 AND age >= 65) { ++seniorFemales...

Quizlet-style Flashcards Page 1: 1. What is the equivalent code for `if (gender == 1) { if (age >= 65) { ++seniorFemales; } }`? a. `if (gender == 1 || age >= 65) { ++seniorFemales; }` b. `if (gender == 1 && age >= 65) { ++seniorFemales; }` c. `if (gender == 1 AND age >= 65) { ++seniorFemales; }` d. `if (gender == 1 OR age >= 65) { ++seniorFemales; }` Correct Answer: b 2. Which methods are overloaded among the given examples? a. A and B are overloaded; C and D are overloaded. b. A and C are overloaded; B and D are overloaded. c. A, B, and C are overloaded. d. All four methods are overloaded. Correct Answer: d 3. What is the correct code for calling the method `public void displayValue(int value)`? a. `int x = 7; void displayValue(x);` b. `int x = 7; displayValue(x);` c. `int x = 7; displayValue(int x);` d. `int x = 7; displayValue(x)` Correct Answer: b Page 2: 4. What is the value of `c` at the end of the code `int c = 8; c++; ++c; c %= 5;`? a. `0` b. `1` c. `3` d. None of the above. Correct Answer: a 5. What are the values of `x` and `y` after executing the code `int x = 25, y = 8; x += y++;`? a. `x = 34, y = 9` b. `x = 25, y = 8` c. `x = 33, y = 8` d. `x = 33, y = 9` Correct Answer: d 6. What is the value of `result` after executing the expression `result = d % a * c + a % b + a;` with `a=4, b=12, c=37, d=51`? a. `119` b. `51` c. `127` d. `59` Correct Answer: a 7. Which keyword indicates the `main` method can be called without creating an object? a. `stable` b. `private` c. `static` d. `public` Correct Answer: c... Page 8: 37. Which `JFrame` constant indicates that the program should terminate when the window is closed by the user? a. `TERMINATE_ON_CLOSE` b. `IMMEDIATELY_CLOSE` c. `EXIT_ON_CLOSE` d. All of the above Correct Answer: c 38. Which of the following most completely describes the steps for setting up event handling for a GUI component? a. Create a class that represents the event handler, attach the `JFrame` to a `JWindow` object and register the event handler. b. Implement an appropriate event-listener interface and register the event handler. c. Create a class that represents the event handler and implement an appropriate event-listener interface. d. Create a class that represents the event handler, implement an appropriate event-listener interface, and register the event handler. Correct Answer: d 39. When the user presses Enter in a `JPasswordField`, the GUI component generates an ____, which is processed by an object that implements the interface ____. a. `ActionEvent`, `ActionListener` b. `ActionEvent`, `ActionEventListener` c. `TextEvent`, `TextListener` d. `TextEvent`, `TextEventListener` Correct Answer: a 40. A `JRadioButton` is different from a `JCheckBox` in that ____. a. A `JRadioButton` is a subclass of `JToggleButton`, `JCheckBox` is not. b. Normally several `JRadioButtons` are grouped together and are mutually exclusive. c. A `JRadioButton` is a type of button, `JCheckBox` is not. d. A `JRadioButton` is a state button, `JCheckBox` is not. Correct Answer: b

Use Quizgecko on...
Browser
Browser