Auto-unboxing, switch, short circuit logical operators & exception handling are core Java basics that sometimes lead to obscure errors if not understood well & often tested in coding tests. Q1. What is wrong with this code?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | public class WhatIsWrong { public static void main(String[] args) { double i = 2; switch (i) { case 1: System.out.println("First class"); break; case 2: System.out.println("Second class"); break; default: break; } } } |
A1. compile-error at…