A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.geeksforgeeks.org/quizzes/java-interface-types-and-comparator/ below:

Quiz about Java Interface types and Comparator

Which of the following statements about functional interfaces is true?

What will be the output of the following code?

Java
@FunctionalInterface
interface Geeks {
    void display();
    default void show() { 
        System.out.println("Default method"); 
        
    }
}
public class Test {
    public static void main(String[] args) {
        Geeks obj = () -> System.out.println("Lambda Executed");
        obj.display();
    }
}

How is a nested interface defined in Java?

Which of the following is NOT true about nested interfaces?

Which of the following is a correct example of a Marker Interface?

What is the primary use of a marker interface in Java?

What is true about Java’s Comparator interface?

What will be the output of the following code?

Java
import java.util.*;
class Student {
    int age;
    Student(int age) { this.age = age; }
}
class AgeComparator implements Comparator<Student> {
    public int compare(Student s1, Student s2) {
        return s1.age - s2.age;
    }
}
public class Test {
    public static void main(String[] args) {
        List<Student> list = Arrays.asList(new Student(20), new Student(18));
        Collections.sort(list, new AgeComparator());
        System.out.println(list.get(0).age);
    }
}

How is Comparator different from Comparable?

What is the benefit of using a lambda expression with a Comparator?

There are 10 questions to complete.

Take a part in the ongoing discussion


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4