Apr 9, 2024
Yes, Its correct. but in case instead of Boolean if we want to return Object then we need to write like this.
public Employee getValidEmployee(String userName) {
if (userName != null && userName.equals("Tom")) {
return new Employee("sumit","singh",15,1000);
}
return null;
}