Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

13. Consider the following code snippet. btOK.setOnAction(new EventHandler () { public void handle(ActionEvent e) { System.out.println(OK clicked); } }); The above code snippet can be

13. Consider the following code snippet.

btOK.setOnAction(new EventHandler() {

public void handle(ActionEvent e) {

System.out.println("OK clicked");

} });

The above code snippet can be replaced by all of the following: which is the best?

a. btOK.setOnAction((e) -> System.out.println("OK cliked"););

b. btOK.setOnAction((ActionEvent e) -> System.out.println("OK Clicked"));

c. btOK.setOnAction(e -> {System.out.println("OK Clicked");});

d. btOK.setOnAction(e -> System.out.println("OK cliked"););

18. Analyze the following code:

public class Test {

public static void main(String[] args) {

Test test = new Test();

test.setAction(() -> System.out.print("Action 1! ")); }

public void setAction(T t) {

t.m1();

}

}

interface T {

public void m1();

public void m2();}

#-note that the interface has more than one abstract methods (not a functional interface):

a. The program displays Action 1.

b. The program displays Action 1 two times

c. The program has a compile error because T is not a functional interface. T contains multiple methods. Lambda notation cannot be used

d. The program would work if you change t.m1() to t.m2().

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Principles Programming And Performance

Authors: Patrick O'Neil, Elizabeth O'Neil

2nd Edition

1558605800, 978-1558605800

More Books

Students also viewed these Databases questions

Question

Knowledge of digital marketing and social media

Answered: 1 week ago