15 Technical Core Java Interview Questions Answers for Experienced Developers

When the sense of a Java Programmer grows inwards the years e.g. when it goes from beginner years ( 2 to 4) to to a greater extent than sense or sort of senior marking ( v to seven years), Core Java Interview Questions besides changes a bit. Of course, basics similar data structure, algorithms, and object-oriented programming remains same, but types of questions volition acquire to a greater extent than advanced too their answers volition definitely demand to live on to a greater extent than detailed too accurate. I often have queries virtually essence Java questions asked to a senior developer of v to 6-year experience, or, sometimes, I am going for an interview of senior Java developer, what form of questions I should expect. This sometimes puzzles me, that in i lawsuit you lot acquire senior, you lot automatically starts taking purpose inwards the interview, too you lot should lead keep an thought of what to await on Interviews, but at the same time, I tin empathize that having an thought of questions earlier going on Interview, helps preparation. Of course, you lot are non going to acquire a interrogation similar the i you lot lead keep faced on 2 to iii years marking Java Interviews, but It besides depends on dissimilar rounds of Interviews.

I lead keep non seen many changes inwards the questions asked on telephonic round, which almost remains same. You volition abide by unopen to fact based, unopen to coding questions too few tricky questions. On the other mitt face-to-face, interviews lead keep acquire to a greater extent than detailed too to a greater extent than tricky, specially alongside nasty follow-ups. 

In this article, I am going to portion some 15 technical essence Java Interview Questions, which I lead keep seen asked senior too experienced developers of four to half dozen years of sense inwards dissimilar interviews, to a greater extent than often than non on telephonic rounds.  I am non posting answers every bit of now, but  you lot tin abide by answers to most of the questions on hither or Javarevisited blog.



If you lot are inwards a hurry too actively looking for a Java Developer Job, you lot tin besides accept assist from unopen to proficient books written to laid upward you lot for Java J2EE interviews. Books like, Java Programming Interview Exposed covers all of import topics for both essence Java too Java EE interviews, which includes basic Java questions, information construction too algorithms, JVM internals too GC tuning, Hibernate too Spring interview questions, JUnit emmet unit of measurement testing questions, too unopen to Java 8 stuff.

It besides covers cognition of other JVM languages similar Scala, Groovy too other platforms similar Android. H5N1 perfect companion to produce good inwards Java interviews.

If you lot desire to laid upward to a greater extent than on the coding side thus  you tin besides cheque out Cracking the Coding Interview, which contains almost 150 programming questions too solutions from technical interviews of big tech companies similar Amazon, Facebook, Google, Twitter, too Microsoft.



15 Core Java Questions For v to half dozen Years Experienced

When the sense of a Java Programmer grows inwards the years e fifteen Technical Core Java Interview Questions Answers for Experienced DevelopersAll these questions lead keep been collected from quite senior developers, which has at to the lowest degree v years of experience. They lead keep seen these questions on dissimilar rounds of their essence Java interviews, including telephonic too face-to-face rounds on dissimilar companies, to a greater extent than often than non on Investment banks similar Barclays, Morgan, RBS too others.


1. What is Busy Spinning? Why Should You Use It inwards Java?
One of the interesting multithreading interrogation to senior Java programmers, busy spinning is a waiting strategy, inwards which a thread simply hold off inwards a loop, without releasing the CPU for going to sleep. This is a really advanced too specialized waiting strategy used inwards the high-frequency trading application when hold off fourth dimension betwixt 2 messages is really minimal.

By non releasing the CPU or suspending the thread, your thread retains all the cached information too instruction, which may live on lost if the thread was suspended too resumed dorsum inwards a dissimilar essence of CPU. 

This interrogation is quite pop inwards high-frequency depression latency programming domain, where programmers are trying for extremely depression latency inwards the hit of micro to milliseconds. See hither to a greater extent than 50+ advanced thread interview questions for experienced programmers. 

When the sense of a Java Programmer grows inwards the years e fifteen Technical Core Java Interview Questions Answers for Experienced Developers



2. What is Read-Write Lock? Does ConcurrentHashMap inwards Java Uses The ReadWrite Lock?
ReadWrite Lock is an implementation of lock stripping technique, where 2 separate locks are used for read too write operation. Since read functioning doesn't modify the state of the object, it's prophylactic to allow multiple thread access to a shared object for reading without locking, too past times splitting i lock into read too write lock, you lot tin easily produce that. 

Java provides an implementation of read-write lock inwards the shape of ReentrantReadWritLock course of written report inwards the java.util.concurrent.lock package. This is worth looking earlier you lot create upward one's heed to write your ain read-write locking implementation. 

Also, the electrical current implementation of java.util.ConcurrentHashMap doesn't utilization the ReadWriteLock, instead, it divides the Map into several segments too locks them separately using dissimilar locks. This agency whatever given time, only a portion of the ConcurrentHashMap is locked, instead of the whole Map. See how ConcurrentHashMap internally plant inwards Java for to a greater extent than detail. 


This essence Java interrogation is besides really pop on senior too to a greater extent than experienced marking Java interviews e.g. four to half dozen years, where you lot await Interviewer to give-up the ghost into to a greater extent than detail, e.g. past times asking you lot to provided an implementation of the read-write lock alongside dissimilar policies. If you lot are an experienced Java programmer, consider reading Java Concurrency inwards Practice to gain to a greater extent than confidence virtually multithreading too concurrency inwards Java. 



3. How to Make an Object Immutable inwards Java? Why Should You Make an Object Immutable?
Well, Immutability offers several advantages including thread-safety, mightiness to cache too effect inwards to a greater extent than readable multithreading code. See here to larn how to brand object Immutable. Once again, this interrogation tin besides give-up the ghost into to a greater extent than particular too depending on your answer, tin convey several other questions e.g. when you lot lift Spring is Immutable, live on create alongside unopen to reasons on Why String is Immutable inwards Java.


4. Which Design Patterns lead keep You Used inwards Your Java Project?
Always await unopen to blueprint patterns related interrogation for Core Java Interview of senior developer position. It's a amend strategy to lift whatever GOF blueprint pattern rather than Singleton or MVC, which almost every other Java developer utilization it. 

Your best bet tin be Decorator pattern or may be Dependency Injection Pattern, which is quite pop inwards Spring Framework. It's besides proficient to lift exclusively the blueprint patterns which you lot lead keep actually used inwards your projection too knows it's tradeoffs. 

It's mutual that in i lawsuit you lot lift a particular blueprint pattern state Factory or Abstract Factory, Interviewer's adjacent interrogation would be, have you lot used this pattern inwards your project? So live on create alongside proper instance too why you lot lead a particular pattern. You tin besides run into this article for to a greater extent than advanced blueprint pattern questions from Java interviews. 



5.  Do you lot know virtually Open Closed Design Principle or Liskov Substitution Principle?
Design patterns are based on object-oriented blueprint principles, which I strongly felt every object-oriented developer too the programmer should know, or, at least, lead keep a basic thought of what are these principles too how they assist you lot to write amend object oriented code. I

f you lot don't know the reply to this question, you lot tin politely state No, every bit it's non expected from you lot to know the reply to every question, but past times answering this question, you lot tin brand your claim stronger every bit many experienced developers neglect to reply basic questions similar this. See Clean Code to larn to a greater extent than virtually object-oriented too SOLID blueprint principles.



6. Which Design Pattern Will You Use to Shield Your Code From a Third Party library Which Will Likely to live on Replaced past times Another inwards Couple of Months?

This is simply i instance of  the scenario-based blueprint pattern interview question. In club to examine the practical sense of Java developers alongside to a greater extent than than v years experience, companies enquire this form of questions.  You tin await to a greater extent than real-world blueprint problems inwards dissimilar formats, unopen to alongside to a greater extent than particular explanation alongside context, or unopen to alongside exclusively intent around. 

One way to shield your code from tertiary political party library is to code against an interface rather than implementation and thus utilization dependency injection to render a particular implementation. This form of questions is besides asked quite ofttimes to experienced too senior Java developers alongside v to seven years of experience.


Question 7)  How  produce you lot forbid SQL Injection inwards Java Code?

This interrogation is to a greater extent than asked to J2EE too Java EE developers than essence Java developers, but, it is nevertheless a proficient interrogation to cheque the JDBC too Security science of experienced Java programmers.

You tin use PreparedStatement to avoid SQL injection inwards Java code. Use of the PreparedStatement for executing SQL queries non exclusively provides amend performance but besides shield your Java too J2EE application from SQL Injection attack. 

On a similar note, If you lot are working to a greater extent than on Java EE or J2EE side, thus you lot should besides live on familiar alongside other security issues including Session Fixation attack or Cross Site Scripting attack and how to resolve them. These are unopen to fields too questions where a proficient reply tin brand a lot of departure on your selection. 


Question 8) Tell me virtually dissimilar Reference types available inwards Java, e.g. WeakReference, SoftReference or PhantomReference? too Why should you lot utilization them?

Well, they are dissimilar reference types coming from java.lang.ref package too provided to aid Java Garbage Collector inwards a instance of depression retentivity issues. If you lot twine an object with WeakReference than it volition live on eligible for garbage collected if in that location are o rigid reference. They tin subsequently live on reclaimed past times Garbage collector if JVM is running depression on memory.

The java.util.WeakHashMap is a special Map implementation, whose keys are the object of WeakReference, thus if exclusively Map contains the reference of whatever object too no other, those object tin live on garbage collected if GC needs memory. See Java Performance The Definitive Guide larn to a greater extent than virtually how to bargain alongside performance issues inwards Java. 


When the sense of a Java Programmer grows inwards the years e fifteen Technical Core Java Interview Questions Answers for Experienced Developers


Question 9) How does acquire method of HashMap plant inwards Java?
Yes, this is nevertheless i of the most pop essence Java questions for senior developer interviews. You tin besides await this interrogation on telephonic round, followed past times lot's of follow-up questions every bit discussed on my post service how does HashMap operate inwards Java

The curt reply to this interrogation is that HashMap is based upon hash tabular array information construction too uses hashCode() method to calculate hash code to abide by the bucket location on underlying array too equals() method to search the object inwards the same bucket inwards instance of a collision. See here to larn a to a greater extent than virtually how does get() method of HashMap plant inwards Java. 



Question 10) Which Two Methods HashMap cardinal Object Should Implement?
This is i of the follow-up questions I was maxim virtually inwards previous questions. Since working of HashMap is based upon hash tabular array information structure, whatever object which you lot desire to utilization every bit cardinal for HashMap or whatever other hash based collection e.g. Hashtable, or ConcurrentHashMap must implement equals() too hashCode() method. 

The hashCode() is used to abide by the bucket location i.e. index of underlying array too equals() method is used to abide by the correct object inwards linked listing stored inwards the bucket inwards instance of a collision. By the way, from Java 8, HashMap besides started using tree information construction to shop the object inwards instance of collision to cut down worst instance performance of HashMap from O(n) to O(logN). See the article for learning to a greater extent than virtually how does HashMap handless collision inwards Java



Question 11) Why Should an Object Used As the Key should live on Immutable? 
This is unopen to other follow-up of previous essence Java interview questions. It's proficient to examine the depth of technical cognition of candidate past times asking to a greater extent than too to a greater extent than interrogation on the same topic. If you lot know virtually Immutability, you lot tin reply this interrogation past times yourself. The curt reply to this interrogation is cardinal should live on immutable so that hashCode() method  always render the same value.

Since hash code returned past times hashCode() method depends on upon the content of object i.e. values of fellow member variables. If an object is mutable than those values tin alter too thus is the hash code. If the same object returns dissimilar hash code in i lawsuit you lot inserted the value inwards HashMap, you lot volition cease upward searching inwards dissimilar bucket location too volition non able to cry upward the object. That's why a cardinal object should live on immutable. It's non a dominion enforced past times the compiler but you lot should accept attention of it every bit an experienced programmer. See the article for to a greater extent than advanced Java Collection interview questions



Question 12) How does ConcurrentHashMap achieves its Scalability? 
Sometimes this multithreading + collection interview interrogation is besides asked as, the departure betwixt ConcurrentHashMap too Hashtable inwards Java. The work alongside synchronized HashMap or Hashtable was that whole Map is locked when a thread performs whatever functioning alongside Map. 

The java.util.ConcurrentHashMap course of written report solves this work past times using lock stripping technique, where the whole map is locked at dissimilar segments too exclusively a particular segment is locked during the write operation, non the whole map. The ConcurrentHashMap also achieves it's scalability past times allowing lock-free reads every bit read is a thread-safe operation.  See here for to a greater extent than advanced multi-threading too concurrency questions inwards Java. 



Question 13) How produce you lot portion an object betwixt threads? or How to move past times an object from i thread to another? 
There are multiple ways to produce that e.g. Queues, Exchanger etc, but BlockingQueue using Producer Consumer pattern is the easiest way to move past times an object from thread to another.



Question 14) How produce abide by if your programme has a deadlock?
By taking thread dump using kill -3, using JConsole or VisualVM), I propose to laid upward this essence coffee interview interrogation inwards to a greater extent than detail, every bit Interviewer definitely likes to give-up the ghost alongside to a greater extent than particular e.g. they volition press alongside questions like, lead keep you lot genuinely done that inwards your projection or not?


Question 15) How produce you lot avoid deadlock spell coding?
By ensuring locks are acquire too released inwards an ordered manner, run into here for particular reply of this question.


That's all on this listing of core Java Interview Questions for senior developers too experienced programmers. I haven't included a lot of interrogation from other of import topics similar Exception handling, Garbage Collection tuning too JVM Internals, which is besides really pop among Java programmers alongside v to half dozen years of experience, maybe I volition include them inwards the next part.  

By the way, if you lot don't abide by the reply of whatever of these essence Java Question, allow me know. I may update the post service alongside a to a greater extent than detailed option, based on my reader's request.

Related Java Interview Questions on other topics
  • Java Questions for Phone Screen Interviews (list)
  • Thread too Concurrency Questions from Java Interviews (list)
  • Java Enum Interview Questions too Answers (list)
  • Java OOP Interview Questions alongside Answers (list)
  • Spring MVC Interview Questions too Answers (list)
  • Hibernate Interview Questiosn alongside Answrs (list)
  • JDBC Interview Questions too Answers (list)
  • Array Concept Interview Questions inwards Java (list)
  • RESTful Web Service Interview Questions (list)
  • Servlet too JSP Interivew Quesitons too Answers (list)
  • Java Web Service Interview Qustions too Answers (list)


References
Oracle's Java SE Tutorials
Java SE 8 API documentation
133+ Java Interview Questions from Last v Years

Subscribe to receive free email updates:

0 Response to "15 Technical Core Java Interview Questions Answers for Experienced Developers"

Posting Komentar