Get the rating of a movie

9 Points
You are given the following class definition (assume all methods are correctly implemented):
public class Movie {

public Movie(String title, int year) { … }
public String getTitle() { … }
public int getYear() { … }
public String getGenre() { … }
public int getRating() { … }
}
For each of the following, write NAMED and TYPED lambda expressions (i.e. LHS is a type and a variable name, RHS is the lambda expression). For the type, use appropriate functional interfaces from the java.util.function and java.util packages.
Q3.14 Points
Get the rating of a movie (do NOT use a method reference)
Enter your answer here
Q3.24 Points
A method reference to create a Movie instance with name and year
Enter your answer here
Q3.36 Points
A predicate for movie objects that are either of the genre “Comedy” with a rating of 4 or more, or genre “Action” with a rating of 3 or less. You may write named and typed supporting predicates, as needed.
Enter your answer here
Q3.45 Points
An expression using a method reference that can be passed as argument to the sort method of a List of movies, for sorting in ascending order of rating.
Enter your answer here
Q4 Class Polymorphism
7 Points
Recall the Point and ColoredPoint classes discussed in lecture. Suppose there is an array Point[] pts that is populated with a mix of Point and ColoredPoint objects. Write a loop to print the color of every ColoredPoint instance in this array, using the ColoredPoint class’s getColor() method. Is your code polymorphic? Argue for why or why not.
Enter your answer here
Q5 Interface Polymorphism
6 Points
There are two kinds of interface polymorphism. Explain each with
the use of Java snippets to show polymorphic behavior.
(Your code doesn’t have to implement any algorithmic logic, just the essential set up needed to support your explanation.)
Enter your answer here
Q6 equals Method
6 Points
Suppose there is class called X. Assume the following objects are created:
Object o = new X();
X x = new X();
In class X, a boolean equals(X x) method is implemented.
Which version of equals: equals(Object) or equals(X), is called in each of the following? Give a 1-2 sentence explanation for your answer.
Q6.13 Points
o.equals(o);
Enter your answer here
Q6.23 Points
x.equals(x);
Enter your answer here
Submit & View Submission

How to create Testimonial Carousel using Bootstrap5

Clients' Reviews about Our Services