Part 1: Java Interview Questions And Answers! If you want to make your career in Java as a Java developer then you need to learn these Core Java Interview Questions and Answers. Join the Java training institutes in Pune and make a successful career in this field. 1. Can we make an array volatile in Java? It is certainly possible to make an array volatile in Java but only the reference which is pointing to an array, not the complete array. If one thread changes the reference variable points to another array will offer a volatile guarantee. Moreover, if there are lots of threads changing the particular array elements then there will not be any happens before assurance offered by the volatile modifier for such modification. 2. Which among these would be easier to write: synchronization code for ten threads or two threads? With respect to writing both will have the same level of complexity as the synchronization is independent of the number of threads and the choice of synchronization could be subject to the number of threads as this offers more conflict. 3. How to call wait() method? Is it possible to use if block or loop, and why? Wait() method should always be called in a loop. The condition will not hold until the thread gets CPU to start running again. Moreover, it is always advised to verify the condition in a loop before continuing. 4. What is regarded as false sharing in the context of multithreading? One of the renowned performance issues on multi-core systems is False sharing whereby each process has a local cache. It is difficult to see it as the thread may be retrieving completely unique global variables that occur close together in memory. 5. What is busy spin, and why to use it? Busy pin is considered as one of the techniques to hold on for events without releasing CPU. This mostly done to avoid losing data in CPU cache which could get lost if the thread is paused and resumed in some other
core. This is quite feasible if you want to wait for a short period of time eg in microseconds or nanoseconds. 6. How do you take thread dump in Java? With the help of kill-3PID in Linux where PID is the process id of Java process, you can take a thread dump of Java application. It is possible to press Ctrl + Break in Windows. The Java classes in Mumbai are very much enough for you to make a successful career in this field. YOU CAN ALSO READ: Top 10 Java Training Institute in Pune!