Sunday, November 24, 2019

15 Technical Nitty-Gritty Coffee 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 score ( five to vii 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 last to a greater extent than detailed too accurate. I often have queries virtually center Java questions asked to a senior developer of five 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 1 time you lot acquire senior, you lot automatically starts taking business office inwards the interview, too you lot should cause got an thought of what to aspect on Interviews, but at the same time, I tin sympathize that having an thought of questions earlier going on Interview, helps preparation. Of course, you lot are non going to acquire a inquiry similar the 1 you lot cause got faced on 2 to three years score Java Interviews, but It besides depends on dissimilar rounds of Interviews.

I cause got non seen many changes inwards the questions asked on telephonic round, which almost remains same. You volition honour approximately fact based, approximately coding questions too few tricky questions. On the other mitt face-to-face, interviews cause got acquire to a greater extent than detailed too to a greater extent than tricky, peculiarly amongst nasty follow-ups. 

In this article, I am going to part some 15 technical center Java Interview Questions, which I cause got seen asked senior too experienced developers of four to six years of sense inwards dissimilar interviews, to a greater extent than often than non on telephonic rounds.  I am non posting answers equally of now, but  you lot tin honour 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 approximately practiced books written to laid you lot for Java J2EE interviews. Books like, Java Programming Interview Exposed covers all of import topics for both center 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 approximately Java 8 stuff.

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

If you lot desire to laid to a greater extent than on the coding side too then  you tin besides depository fiscal establishment gibe 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 five to six 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 cause got been collected from quite senior developers, which has at to the lowest degree five years of experience. They cause got seen these questions on dissimilar rounds of their center 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 inquiry 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 last lost if the thread was suspended too resumed dorsum inwards a dissimilar center of CPU. 

This inquiry is quite pop inwards high-frequency depression latency programming domain, where programmers are trying for extremely depression latency inwards the make 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 dry ground of the object, it's rubber to allow multiple thread access to a shared object for reading without locking, too past times splitting 1 lock into read too write lock, you lot tin easily create that. 

Java provides an implementation of read-write lock inwards the cast of ReentrantReadWritLock cast inwards the java.util.concurrent.lock package. This is worth looking earlier you lot determine to write your ain read-write locking implementation. 

Also, the electrical current implementation of java.util.ConcurrentHashMap doesn't purpose the ReadWriteLock, instead, it divides the Map into several segments too locks them separately using dissimilar locks. This way 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 center Java inquiry is besides really pop on senior too to a greater extent than experienced score Java interviews e.g. four to six years, where you lot aspect Interviewer to locomote past times into to a greater extent than detail, e.g. past times asking you lot to provided an implementation of the read-write lock amongst 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 upshot inwards to a greater extent than readable multithreading code. See here to larn how to brand object Immutable. Once again, this inquiry tin besides locomote past times into to a greater extent than particular too depending on your answer, tin direct several other questions e.g. when you lot cite Spring is Immutable, last cook amongst approximately reasons on Why String is Immutable inwards Java.


4. Which Design Patterns cause got You Used inwards Your Java Project?
Always aspect approximately pattern patterns related inquiry for Core Java Interview of senior developer position. It's a ameliorate strategy to cite whatever GOF pattern pattern rather than Singleton or MVC, which almost every other Java developer purpose it. 

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

It's mutual that 1 time you lot cite a particular pattern pattern tell Factory or Abstract Factory, Interviewer's side past times side inquiry would be, have you lot used this pattern inwards your project? So last cook amongst proper instance too why you lot direct a particular pattern. You tin besides run into this article for to a greater extent than advanced pattern 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 pattern principles, which I strongly felt every object-oriented developer too the programmer should know, or, at least, cause got a basic thought of what are these principles too how they assist you lot to write ameliorate object oriented code. I

f you lot don't know the reply to this question, you lot tin politely tell No, equally 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 equally 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 pattern principles.



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

This is simply 1 instance of  the scenario-based pattern pattern interview question. In social club to assay the practical sense of Java developers amongst to a greater extent than than five years experience, companies inquire this form of questions.  You tin aspect to a greater extent than real-world pattern problems inwards dissimilar formats, approximately amongst to a greater extent than particular explanation amongst context, or approximately amongst exclusively intent around. 

One way to shield your code from 3rd political party library is to code against an interface rather than implementation and too then purpose dependency injection to furnish a particular implementation. This form of questions is besides asked quite often to experienced too senior Java developers amongst five to vii years of experience.


Question 7)  How  create you lot preclude SQL Injection inwards Java Code?

This inquiry is to a greater extent than asked to J2EE too Java EE developers than center Java developers, but, it is nevertheless a practiced inquiry to depository fiscal establishment gibe 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 ameliorate 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, too then you lot should besides last familiar amongst other security issues including Session Fixation attack or Cross Site Scripting attack and how to resolve them. These are approximately fields too questions where a practiced 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 purpose 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 wind an object with WeakReference than it volition last eligible for garbage collected if in that location are o rigid reference. They tin afterwards last 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, thence if exclusively Map contains the reference of whatever object too no other, those object tin last garbage collected if GC needs memory. See Java Performance The Definitive Guide larn to a greater extent than virtually how to bargain amongst 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 1 of the most pop center Java questions for senior developer interviews. You tin besides aspect this inquiry on telephonic round, followed past times lot's of follow-up questions equally discussed on my ship how does HashMap locomote inwards Java

The curt reply to this inquiry is that HashMap is based upon hash tabular array information construction too uses hashCode() method to calculate hash code to honour 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 telephone commutation Object Should Implement?
This is 1 of the follow-up questions I was proverb virtually inwards previous questions. Since working of HashMap is based upon hash tabular array information structure, whatever object which you lot desire to purpose equally telephone commutation for HashMap or whatever other hash based collection e.g. Hashtable, or ConcurrentHashMap must implement equals() too hashCode() method. 

The hashCode() is used to honour the bucket location i.e. index of underlying array too equals() method is used to honour 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 back 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 last Immutable? 
This is approximately other follow-up of previous center Java interview questions. It's practiced to assay the depth of technical cognition of candidate past times asking to a greater extent than too to a greater extent than inquiry on the same topic. If you lot know virtually Immutability, you lot tin reply this inquiry past times yourself. The curt reply to this inquiry is telephone commutation should last 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 thence is the hash code. If the same object returns dissimilar hash code 1 time you lot inserted the value inwards HashMap, you lot volition cease upwards searching inwards dissimilar bucket location too volition non able to think the object. That's why a telephone commutation object should last immutable. It's non a dominion enforced past times the compiler but you lot should accept attention of it equally 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 inquiry is besides asked as, the departure betwixt ConcurrentHashMap too Hashtable inwards Java. The work amongst synchronized HashMap or Hashtable was that whole Map is locked when a thread performs whatever functioning amongst Map. 

The java.util.ConcurrentHashMap cast 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 equally 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 create you lot part an object betwixt threads? or How to locomote past times an object from 1 thread to another? 
There are multiple ways to create that e.g. Queues, Exchanger etc, but BlockingQueue using Producer Consumer pattern is the easiest way to locomote past times an object from thread to another.



Question 14) How create honour if your computer programme has a deadlock?
By taking thread dump using kill -3, using JConsole or VisualVM), I propose to laid this center coffee interview inquiry inwards to a greater extent than detail, equally Interviewer definitely likes to locomote past times amongst to a greater extent than particular e.g. they volition press amongst questions like, cause got you lot genuinely done that inwards your projection or not?


Question 15) How create you lot avoid deadlock piece 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 inquiry from other of import topics similar Exception handling, Garbage Collection tuning too JVM Internals, which is besides really pop among Java programmers amongst five to six years of experience, maybe I volition include them inwards the next part.  

By the way, if you lot don't honour the reply of whatever of these center Java Question, allow me know. I may update the ship amongst 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 amongst Answers (list)
  • Spring MVC Interview Questions too Answers (list)
  • Hibernate Interview Questiosn amongst 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 five Years

No comments:

Post a Comment