Skip to main content

Posts

Java Tricky Interview Questions

Java Tricky Questions 1. Is there any difference between a = a + b and a += b expressions? When we add two integral variables e.g. variables of type byte, short, or int in Java, then they are first promoted to int type, and then addition happens. The += operator implicitly casts the result of addition into the type of variable used to hold the result. What happens when you put return statement or System.exit () on try or catch block? Will finally block execute? It is a popular tricky Java interview question. Most of the programmers think that no matter what the finally block will always execute. This question challenges that concept by putting a return statement in the try or catch block or calling System.exit() from try or catch block. You can answer by saying that finally block executes even if we put a return statement in the try block or catch block. But finally block does not execute if you call System.exit() from try or catch block. 2. What does the expre

Java 8 interview Questions

Java 8 1. What are the new features released in Java 8? The new features released in Java 8 are: 1.      Lambda Expression 2.      Stream API 3.      Date and Time API 4.      Functional Interface 5.      Interface Default and Static Methods 6.      Optional 7.      Base64 Encoding and Decoding 8.      Nashorn JavaScript Engine 9.      Collections API Enhancements 10.   Concurrency Enhancements 11.   1Fork/Join Framework Enhancements 12.   Spliterator 13.    Internal Iteration 14.    Type Annotations and Repeatable Annotations 15.     Method Parameter Reflection 16.     JVM Parameter Changes 2.What are the main benefits of new features introduced in Java 8? The main benefits of Java 8 features are: 1.      Support for functional programming by Lambda and Streams 2.      Ease of high volume data processing by Streams 3.      Ease of use by getting Parameter names through Reflection 4.      Reusable code with enhanced Collection AP