File Name: latest java interview questions and answers .zip
In this article, we have compiled the most frequently asked Java Interview Questions.
Follow along to brush up the most common advanced Java interview questions and answers that may win you a next job offer. Each Java source file is compiled into a bytecode file, which is executed by the JVM.
The main distinction between fail-fast and fail-safe iterators is whether or not the collection can be modified while it is being iterated. Fail-safe iterators allow this; fail-fast iterators do not. Fail-fast iterators operate directly on the collection itself. During iteration, fail-fast iterators fail as soon as they realize that the collection has been modified i.
Thanks a lot Anonymous for informing us about subtle details about Substring method , I guess Interviewer was looking for that information in his question "How does substring inside String works? Hi Scott, your solution is correct but with the advent of java 5 and now guarantee of volatile keyword and change in Java memory model guarantees that double checking of singleton will work.
Hi Anand, Thanks for answering question "How does substring inside String works? Use can use a static holder to handle the singleton creation instead of double checked mechanism. Stored Procedure Error: One way to signal an error is from what is returned. Consider different factories each extended from an Abstract Factory and responsible for creation of different hierarchies of objects based on the type of factory.
Each individual factory would be responsible for creation of objects in that genre. I only see 18 questions and most of them are answered wrong or not at all Also, your english is terrible.
If found s will be made to refer to the found object. If not found, a new String object is created, added to the pool and s is made to refer to the newly created object. Additionally an entry for string "Test" is made in the string constant pool, if its not already there. So assuming string "Test" is not in the pool, the first declaration will create one object while the second will create two objects.
Factory just create one of the subclass. As I remember in GoF: AF could create widgets for different types of UI buttons, windows, labels , but we could have windows, unix etc.
UI types, created objects are related by domain. PS full disclosure, I am actually a current student of IIB and I do receive help with recruiting eg mock interview in exchange for letting other students know about the Free Tutorials. These Java interview question are equally beneficial for 2 years experience or beginners, 4 years experience Java developers intermediate and more than 6 years experience of Java developer i.
Advanced level. Most of the questions comes under 2 to 4 years but some of them are good for 6 years experience guy as well like questions related to executor framework.
I agree most of these java interview questions asked during experienced developers and senior developers level. Another popular Java interview question is why Java does not support multiple inheritance, passing reference, or operator overloading, can you please provide answers for those questions. Hi I am looking for some real tough Java interview question which explores some advanced concept and make sense. If you have Java questions asked in Nomura or any of these banks please share.
I heard that they mostly asked Garbage Collection, Generics, Design and profiling related questions to senior candidate but some real questions from those companies will really help. Hi Javarevisited, looking core java interview questions and answers for experienced in pdf format so that I can use if offline, Can you please help to convert these Java questions in pdf?
Javin For question 7 -we usually handle the exception and divert the user to a standard error page with the exception trace as a page variable. The user will have an option to email the support team through a button click and the error trace gets sent to support. This way we can know what went wrong in the application and fix it. Typically these kind of errors are due to poor data error handling in stored procedure like a missed null check or a char variable of incorrect size etc which are exposed only when I consistent data flows into the app which was never tested during development or uat.
Anand, you bring an important point. I guess purpose of that java interview question is to check whether you verify inputs in Java or not before passing to Stored procedure and similarly when you receive response. Thanks for your comment mate. Please keep us posting some more tough Java interview question from and , which is recent. Urgently required, interview scheduled in two days. Some Java programmer ask for Java questions for 2 years experience, Java questions for 4 years experience, questions for Beginners in Java, questions for experienced Java programmer etc etc.
Basically all these are just short cut, you should be good on what are you doing. You automatically gain experience while working in Java and should be able to answer any Java question up-to your level. Hi , Does Amazon or Microsoft ask questions on Java? I am looking for some Java questions asked on Microsoft, Amazon and other technology companies, if you know please share.
You have no control over what questions get asked in job interviews. All you can do is brush up on the key fundamentals. Hi Javin, I'd like to thank you for putting huge effort in creating such nice collection. Kindly update following in your blog: Regarding Question It will be nice for others if you can update this in your blog. Hi Ravi, where did you read that? I have never heard about String object created on both heap and pool.
Object is placed into pool when you call intern method on String object. Can you please suggest some latest Java interview questions from , and what is trending now days. Questions like Iterator vs Enumeration is way older and I think latest question on Java is more on Concurrency. In addition, the literal "Test" will be placed in the pool. Although, questions are good, you can add lot more interview questions form Java 5, 6 and Java 7.
Even lamda expression from Java 8 can be a nice question. I remember, having interview with Amazon, Google and Microsoft, there were hardly any Java question, but when I interviewed by Nomura, HeadStrong, and Citibank, there are lots of questions from Java, Generics, Enum etc. Lesson learned, always research about what kind of question asked in a company, before going to interview. I am preparing for Java interview, and looking for recent questions asked in , or may be in last couple of month.
If you can get question from Singapore, HongKong or London, that would be really helpful, but I don't mind question form Pune, Bangalore or Mumbai even. Cheers Dheeraj. Hi, for number 19 it might be better to use System.
I think, you should also include questions from Garbage Collection tuning, Java concurrency package, very hot at the moment.
What is the difference between creating String as new and literal? India is mostly about theoretical knowledge e. USA in particular is more about Code, they will give you a problem and ask you to code solution , write unit test, produce design document in limited time usually 3 to 4 hours.
Trends on other countries are also more balanced towards code e. I heard they are asking new features introduced in Java 6 as well as Java 7.
Please help. How HashMap works, this question was asked to me on Barclays Capital Java Interview question, would hae read this article before, surely helped me. On the contrary,when we invoke intern method on s1 and then compare it returns true as it adds string to pool which is normal working of intern method.
Please correct me if I am wrong. I have an interview with Citibank Singapore for Algorithmic trading developer position, and expecting few Java questions? Nikhil: Question 19 To find out time taken by method to execute System. I am copying and pasting same here.. In this simple case, "abc" will go in the pool and s will refer to it. In this case, because we used the new keyword, Java will create a new String object in normal nonpool memory, and s will refer to it.
In addition, the literal "abc" will be placed in the pool. These questions are quite basic and only useful for freshers or beginners Java developers.
I wouldn't say, you can expect this question as Senior Java developer. Everyone knows answers, there is nothing special about it. I agree with Xhotery, this questions are from and years, now it's In order to crack Java interview today, you need to focus extensively on JVM internals, deeper knowledge of Java Concurrency, sophisticated open source library and good knowledge of frameworks like Spring, Hibernate, Maven, and even bit of functional programming knowledge is required.
In recent Java interviews, peoples are asking about lambdas of Java 8 and How it's going to improve performance, questions about functional interface and new date and time library. Even questions from Java 7 e. So be more advanced and prepare relevant questions, which is popular in , not two years back. These questions and answers are ok, but they look more suited for junior developers than senior engineers to me. Just few quick remarks from me: 1. Immutability in Java is not that easy to achieve, as long as we have reflexion.
Of course, in theory, reflexion can be disabled from a security provider. But in practice, a Java application uses several technologies that rely on reflexion anything that does dependency injection Spring, EJB containers etc.
In Java a java-core environment, singleton means single instance per class loader not per application! In other contexts it may mean single instance per container, etc. Your answer here is absolutely wrong. On one hand, if you just invoke that method for the very first time, you'll not find the net amount of time taken by method execution, but the gross amount of time including method execution plus class loading time for all classes that are referred for the first time inside that method.
Second thing, by measuring that way, you completely ignore how java works: all the adaptive optimization the JIT does at runtime dramatically changes the execution time after a number of method calls. Actually, the first call of a method is the wrongest way to measure its execution time. Reference : Effective Java second edition item 5 or 6 It will be nice for others if you can update this in your blog.
Hi, The Answer to 3. When creating string using new will create two copies one in heap and another in string pool. And the object reference will be initially in heap.
Inorder to make the object reference to string pool we need to call intern on the string.
What is the right data type to represent a price in Java? Answer: BigDecimal, if memory is not a concern and Performance, is not critical, otherwise double with predefined precision. What is a class in Java? Answer: Java encapsulates the codes in various classes which define new data types. These new data types are used to create objects. What is a JVM? Explain method overloading?
There is the list of core Java interview questions. If there is any core Java interview question that has been asked to you, kindly post it in the ask question section. The answers to the Core Java interview questions are short and to the point. The core Java interview questions are categorized in Basics of Java interview questions, OOPs interview questions, String Handling interview questions, Multithreading interview questions, collection interview questions, JDBC interview questions, etc.
Thanks a lot Anonymous for informing us about subtle details about Substring method , I guess Interviewer was looking for that information in his question "How does substring inside String works? Hi Scott, your solution is correct but with the advent of java 5 and now guarantee of volatile keyword and change in Java memory model guarantees that double checking of singleton will work. Hi Anand, Thanks for answering question "How does substring inside String works? Use can use a static holder to handle the singleton creation instead of double checked mechanism.
In this post, we will see Java interview questions for 5 to 6 years experience. When you have 5 years of experience as java developer, you need to have a good understanding of collections , multithreading concepts.
Download PDF We have compiled the most frequently asked Java Interview Questions and Answers that will help you prepare for the Basic Java interview questions that an interviewer might ask you during your interview. In this list of Basic Java interview questions, we have covered all commonly asked basic and advanced Core Java interview questions with detailed answers to help you clear the job interview. The following list contains important Core Java interview questions for freshers as well as Java interview questions and answers for experienced programmers to help them prepare for the interview.
Core Java Interview Questions and Answers for Freshers and of a class is invoked every time an object is created with new keyword.