Project Management Professional: Core Java Interview questions!

Tuesday, July 21, 2020

Core Java Interview questions!

Core Java Interview questions



1.Explain the concept of boxing, unboxing, autoboxing, and auto unboxing.

Answer:

  • Boxing: The concept of putting a primitive value inside an object is called boxing.

  • Unboxing: Getting the primitive value from the object.

  • Autoboxing: Assigning a value directly to an integer object.

  • Auto unboxing: Getting the primitive value directly into the integer object.


    2.What will happen if you call return statement or System.exit on try or catch block ? will finally block execute? This is a very popular tricky Java question and its tricky because many programmer think that finally block always executed. This question challenge that concept by putting return statement in try or catch block or calling System.exit from try or catch block. Answer of this tricky question in Java is that finally block will execute even if you put return statement in try block or catch block but finally block won't run if you call System.exit form try or catch.


    3.Can you override private or static method in Java ? Another popular Java tricky question, As I said method overriding is a good topic to ask trick questions in Java. Anyway, you can not override private or static method in Java, if you create similar method with same return type and same method arguments that's called method hiding.


No comments: