### Question:
LambdaExamples { public static void useConsumer(Consumer<String> consumer){ String foo = "foo"; System.out.println("Before consumer"); consumer.accept(foo); System.out.println("After consumer"); }  static void useRunnable(Runnable runnable); static void useConsumer(Consumer<String> consumer); static String usePredicate(Predicate<String> predicate); static int useFunction(Function<String, Integer> function);  }### Answer:
@Test public void testConsumer() { Consumer<String> anonymousClass = new Consumer<String>() { @Override public void accept(String s) { System.out.println(s.toUpperCase()); } }; Consumer<String> lambda = s -> System.out.println(s.toUpperCase()); LambdaExamples.useConsumer(anonymousClass); LambdaExamples.useConsumer(lambda); LambdaExamples.useConsumer(s -> System.out.println(s.toUpperCase())); }