In the code below, I understand the functioning of getAgentOrConsumer1() method - it will return an object which can be either of the child type. But how is the getAgentOrConsumer2() method different?
public class Scratchpad {
public static Optional<User> getAgentOrConsumer1() {
}
public static Optional<? extends User> getAgentOrConsumer2() {
}
}
class User {
}
class Agent extends User {
}
class Consumer extends User {
}