Q. What is the output of the below Java code snippet that use Autoboxing and Unboxing?

Code:
public class AutoUnboxingTest1
{
  public static void main(String[] args)
  {
    int apple1 = 10;
    Integer apple2 = 10;
    if(apple1 == apple2)
      System.out.println("apple1=apple2");
    else
      System.out.println("apple1!=apple2");
  }
}
  • (A) apple1!=apple2
  • (B) apple1=apple2
  • (C) Compiler error
  • (D) None of these
πŸ’¬ Discuss
βœ… Correct Answer: (B) apple1=apple2

You must be Logged in to update hint/solution

πŸ’¬ Discussion


πŸ“Š Question Analytics

πŸ‘οΈ
256
Total Visits
πŸ“½οΈ
4 y ago
Published
πŸŽ–οΈ
Ram Sharma
Publisher
πŸ“ˆ
93%
Success Rate