Normally, default is not necessary in a switch statement. However, in the following situation the code successfully compiles only when I uncomment the default statement. Can
what happens when xyz is null in your code example? In that case the method is missing a return statement.