kx *g1: Write a public interface namedFundamentalInterface with abstract methods
ID: 3708896 • Letter: K
Question
kx *g1: Write a public interface namedFundamentalInterface with abstract methods named"bed * "tender", "shit", and "vote" all of which take no parameters and have return type int Then write a public class named FundamentalComparator that implements the Comparator * interface with FundamentalInterface as the type parameter. Then implement the compare * method such that it will sort instances that implement FundamentalInterface by the return value of "bed" in increasing order when used as the comparator in a call to *Collections.sortExplanation / Answer
public interface FundamentalInterface { int bed(); int tender(); int shit(); int vote(); } import java.util.Comparator; public class FoundamentalComparator implements Comparator { @Override public int compare(FundamentalInterface f1, FundamentalInterface f2) { return Integer.compare(f1.bed(), f2.bed()); } }Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.