Top 10 Java Interview Questions & Answers
As a candidate for Java development you would definitely like to know the best possible questions you might face in your next Java Interview. Thought the questions change from one interviewer to another, we would like to put together a set of questions considering that it is expected from you to know the correct answers to these questions.
List of Java Freelancers
Question 1
What is JVM?
Answer: JVM stands for Java Virtual Machine. It is an abstract computing machine or a virtual machine. It is platform independent execution environment that converts Java bytecode into machine language and executables.
*Tip: How the code is executed is an important thing for developer to know for using best coding practices.
Question 2
What is type casting in Java?
Answer: Type casting means treating a variable of one type in your code as though it is another type.
*Tip: Some of the questions could be language independent so can be asked in any software development role interview
Question 3
Where all you can use Java code?
Answer: Java is a very mature language and can be used in all type of development like desktop, web, embedded or mobile app development. Android phones use Java as their primary language.
*Tip: Java is one of the basic programming / coding language and the developer is supposed to know where all his skills can be used
Question 4
What is the key difference between Java and J2EE or JEE?
Answer: When we say only Java, we are talking about Java standard edition which is normally used for developing desktop applications whereas Java Enterprise edition (which was called as Java2 platform earlier) is mainly used for applications running on server like web sites or web based applications
*Tip: Client side and server side coding related questions are most likely in technical interviews
Question 5
What is IDE in development world and which IDEs are available for Java coding?
Answer: IDE stands for Integrated Development Environment. This is a software application which helps developers to write and debug the code easily, Java has multiple IDEs. Some of the famous ones are Eclipse, NetBeans, JCreator, IntelliJ IDEA.
*Tip: You may be asked to explain some more details about the IDE you use. Remember, one answer can always lead to next question.
Question 6
When do you use a Do – While loop? What’s the syntax?
Answer: A Do while loop executes group of Java statements as long as the boolean condition evaluates to true.
Do{
<Block of statements>;
}while(<boolean condition>);
*Tip: Yes, asking syntax for common functions can be expected in your interview.
Question 7
Will the below snippet compile properly? If yes, what will be output?
public class JavaTest
{
public static void main(string[] args)
{
if(null==null)
{
System.out.println(“Java Test”);
}
}
}
Answer: Yes, the code will compile properly and the output will be Java Test
*Tip: writing snippets or analysing them and understanding them is part of developer’s job.
Question 8
What are JavaBeans?
Answer: In the Java Platform, JavaBeans are classes that encapsulate many objects into a single object (the bean). They are serializable, have a zero-argument constructor, and allow access to properties using getter and setter methods.
*Tip: Related technologies to the core coding will be always asked. It is not expected for you to be using everything (especially if you are a beginner or only a couple of years into a technology) but you should at least know these things at conceptual level
Question 9
What is a CMS and which are some of the famous Java based CMS?
Answer: CMS or a Content Management System is an Application which allows to manage, organise, create, edit and publish a website easily as a developer.
Alfresco, Magnolia, LogicalDOC, Asbru, OpenCMS, Walrus, Pulse, MeshCMS, Liferay, DotCMS, Hippo are some of the famous Java based CMS
*Tip: CMS is one of the key part in any web development in today’s world and knowledge about a few CMS systems is going to make your life easy
Question 10
What is the key difference between JSP and Java Servlet?
Answer: JavaServer Pages (JSP) is a technology that helps software developers create dynamically generated web pages based on HTML, XML, or other document types. Released in 1999 by Sun Microsystems, JSP is similar to PHP and ASP, but it uses the Java programming language.
A servlet is a Java class that is used to extend the capabilities of servers that host applications accessed by means of a request-response model. Although servlets can respond to any type of request, they are commonly used to extend the applications hosted by web servers. For such applications, Java Servlet technology defines HTTP-specific servlet classes.
Servlets are already compiled which also creates dynamic web content. JSP run slower compared to Servlet as it takes compilation time to convert into Java Servlets.
*Tip: Java is a very mature language with multiple things being built around and is constantly evolving, so JSP, Servlets, JavaBins, JEE, Java in Mobile App development is all equally important for a developer to use maximum potential of this strong language
We hope you have got the gist of important questions which can help you prepare for your interview
All the Best!