As Java is becoming more and more relevant to our computer culture, a lot of freshers are looking to find jobs working with Java. This means competition is fierce, and those who are looking for jobs in the field may want to look at some java interview questions and answers for freshers.
Q: Name a key element of Java, and tell me why it’s so important.
A: Java isn’t dependent on the platform it’s written in. So, if we were to write and compile code in Linux, we could then execute the code in Windows. This makes Java a more flexible code.
Explanation: This question doesn’t have one concrete answer. Instead, it shows the employer that you can think creatively. It also show where you values as a programmer lie.
Q: Distinguish between JVM, JDK, and JIT.
A: JVM stands for Java Virtual Machine, JDK stands for Java Development Kit, and JIT stands for Just-in-Time compilation.
Explanation: You’ve got to understand the acronyms to properly communicate with your employers.
Q: Explain garbage collection.
A: Garbage collection is Java’s way of properly allocating resources. It finds the threads that aren’t being used by the program and deleting them.
Explanation: It’s important to understand all the elements of the program.
Q: Define daemon threads.
A: Daemon threads are threads that aren’t high priority. Currently running daemon threads won’t prevent the shutdown of JVM.
Explanation: Once again, you have to know the program.
Q: Explain the relationship between constructors and methods.
A: A constructor is a type of method. It’s responsible for creating the objects of its class.
Explanation: Let’s say it once more, with feeling this time. You’ve got to know Java.
Q: What separates Java from all other code?
A: Java is platform independent.
A: Java is one of the simpler codes to learn. In fact, it was designed for simplicity.
Explanation: This is another creative question.
Q: If a class has an abstract method, does that mean the whole class is abstract?
A: Yes, and you have to declare it as such.
Explanation: If you made a mistake with this on the job, it could mess up a lot of code.
Q: Name the four states of a thread.
A: Dead, waiting, running, and ready.
Explanation: This shows a familiarity with the program.
Q: Is it possible to subclass a final class?
Explanation: You have to know the program.
Q: What is one of the major disadvantages of using locks?
A: Sometimes two threads try using the same resources. This is known as a deadlock.
Explanation: This shows the employer that you know the advantages and disadvantages that come with various ways of working.
These are the core Java interview questions and answers for freshers. If you’re a fresher, and you’ve answered these Java interview questions for freshers, you’re sure to have a leg up on the competition.
Why? Because you prepared. And preparation is what separates the professional from the dilettante.
Image credit: http://indfun.com/fresher-interview/fresher-hr-round-interview-questions-and-answers-part4/