Top 10 Tough Core Java Interview Questions Answers for Programmers (original) (raw)
tough core Java interviews questions and answers
What is a tough core java interview question? Why do people look for tough Java questions before going for an interview? well, I don't think I need to answer these tough questions because it's pretty natural to prepare for tough questions even if you are not expecting tough questions from core Java. If you are prepared for the tough and tricky Java interview question then you feel more confident and answer other Java interview questions with confidence.
On the other hand, if you are not prepared for tough and tricky core Java questions then seeing them on Java interview or written test may surprise you. But the definition of tough core Java questions is not universal, the same Java question which is easy for one programmer might be tough for other Java programmers.
That's why it's best to prepare your own list of tough interview questions before appearing on any Java job interview. In this article, I am going to share you with my Top 10 tough core Java interview questions and answers, which may help you in the Java interview.
10 tough Java interview question and answer
Here is my list of 10 tough or tricky Java interview questions. These questions are mostly from Core Java and I have not included J2EE questions. As I said you may know answers to these tough Java questions or you may not even find it tough enough to challenge your Java knowledge but once upon a time these were asked in various Java interviews and many programmers including my friends and colleagues find them tough to answer.
1. Why wait and notify is declared in Object class instead of Thread?
Another tough java question, how can you answer this question if you are not designed Java programming language. anyway, some common sense and deep knowledge of Java programming help to answer such tough core java interview questions.
2. Why are multiple inheritances not supported in Java?
I found this core Java question really tough to answer because your answer may not satisfy the Interviewer, in most cases Interviewer is looking for specific points and if you can bring them, they would be happy.
The key to answering this kind of tough question in Java is to prepare the topic well to accommodate any follow-ups. See Why multiple inheritances are not supported in Java for an answer to this tough Java question.
3. Why does Java not support operator overloading?
One more similar category of tough Java questions. C++ supports operator overloading than why not Java? this is the argument Interviewer will give to you and sometimes even say that the + operator is overloaded in Java for String concatenation, Don't be fooled by such arguments.
My favorite Java interview question is tough, tricky but at the same time very useful as well. Some interviewer also asks this question as to Why String is final in Java. look at this post for some points which make sense on Why String is final or immutable in Java
5. Why char array is preferred to store passwords than a String in Java?
Another tricky Java question which is based on String and believes me there is only a few Java programmer which can answer this question correctly.
This is a really tough core Java interview question and again the solid knowledge of String is required to answer this.
You can further see Why char array is better than String for storing the password in Java to find out the answer to this tough Java question.
6. How to create a thread-safe singleton in Java using double-checked locking?
This Java question is also asked as What is a thread-safe singleton and how do you write it. Well, Singleton was created with double-checked locking before Java 5 was a broker and it's possible to have multiple instances of Singleton if multiple threads try to create an instance of Singleton at the same time.
7. Write a Java program to create a deadlock in Java and fix it?
One of the classical but t_ough core Java interview questions_ and you are likely to fail if you have not been involved in the coding of multi-threaded concurrent Java applications. See how to create and prevent deadlock in Java for the complete answer to this tough core Java interview question
8. What happens if your Serializable class contains a member which is not serializable? How do you fix it?
No, you can not override the static method in Java but it's not a compile-time error to declare the exact same method in a subclass, That is called method hiding in Java. You can further see Can you override the static method in Java for a complete answer to this tough Java interview question.