Which one of the following types is not allowed for the expression in a switch statement?
a.
enum
b.
float
c.
int
d.
long correct answers enum
Which of the following can a class NOT be used for?
a.
a container for static methods (subroutines)
b.
a container for static variables
c.
a primitive type
d.
a type for method parameters
e.
a type for variables correct answers a type for variables
What is the output of the following Java program?
class Food { void flavor() { System.out.println("bland"); } } class Pepper extends Food { void
flavor() { System.out.println("spicy"); } } public class Lunch { public static void main(String[]
args) { Food lunch = new Pepper(); lunch.flavor(); } }
,a.
bland
b.
bland
spicy
c.
no output
d.
spicy
e.
the program does not compile correct answers bland
spicy
Consider the following first line from a Java method definition.public static boolean compute(int
n, float x) {Which one of the following lines could begin a method that legally overloads the
above method?
a.
private static boolean compute(int n, float x) {
b.
public boolean compute(int n, float x) {
c.
public static int compute(int n, float x) {
d.
public static boolean compute(float n, int x) {
e.
public static boolean compute(int x, float n) { correct answers b.
public boolean compute(int n, float x) {
, Consider the following Java program. Which statement registers an object to receive events?
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.stage.Stage;
import javafx.application.Platform;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.HBox;
import javafx.scene.control.Button;
public class TestFX extends Application {
public void start(Stage stage) {
Button quitButton = new Button("Quit");
quitButton.setOnAction(e -> Platform.exit());
HBox buttonBar = new HBox(quitButton);
BorderPane root = new BorderPane();
root.setBottom(buttonBar);
Scene scene = new Scene(root, 100, 50);
stage.setScene(scene);
stage.show();
}
public static void main(String[] args) {
launch(args);
}
}
a.
import javafx.scene.control.Button;
b.