Question: What will be printed? public class Test { public static void main(String[] args) { Test test = new Test(); test.setAction2(e -> System.out.print(e * e)); }

What will be printed?

public class Test { public static void main(String[] args) { Test test = new Test(); test.setAction2(e -> System.out.print(e * e)); } public void setAction2(T2 t) { t.m(2.0); }}interface T2 { public void m(Double d);}

a. 4.0

b. compile error

c. runtime error

d. nothing

2. consider the following code, and select the best answer:

Text text = new Text(20, 20, "A");

pane.getChildren().add(text);

text.setOnKeyPressed(e -> {

switch (e.getCode()) {

case DOWN: text.setY(text.getY() + 10); break;

case UP: text.setY(text.getY() - 10); break;

case LEFT: text.setX(text.getX() - 10); break;

case RIGHT: text.setX(text.getX() + 10); break;

default: if (e.getText().length() > 0)

text.setText(e.getText());

}

});

a. Compile error

b. If you type DOWN, the text A will move down 10 pixels

c. If you press down arrow key, the text A will move down 10 pixels

d. If you press down arrow key, the text A will move up 10 pixels

4. To handle the mouse click event on a pane p, register the handler with p using ______.

a. p.setOnMouseClicked(handler);

b. p.setOnMouseDragged(handler);

c. p.setOnMouseReleased(handler);

d. p.setOnMousePressed(handler);

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!