Technical interview questions and answers are essential for any Java Interview because Java is one of the most widely used programming languages in software development. Companies expect candidates to know OOP concepts, multithreading, exceptions, JDBC, collections, and real-time coding questions. Java interviews are commonly part of campus placements and software development roles in companies such as TCS, Infosys, Wipro, Cognizant, and Accenture. For freshers and job seekers, understanding Java concepts clearly makes it easier to clear technical rounds, online coding tests, and project discussions. This guide includes the most important and frequently asked Java interview questions with detailed explanations to help you prepare efficiently. These questions will help you gain confidence during software developer interviews and competitive placement tests.
Java professionals should deepen their expertise through J2EE development concepts and data structures fundamentals
Showing 10 of 301 questions
281. What is the default value of the local variables?
The local variables are not initialized to any default value, neither primitives nor object references. If you try to use these variables without initializing them explicitly, the java compiler will not compile the code. It will complain abt the local varaible not being initilized..
282. Can a public class MyClass be defined in a source file named YourClass.java?
No the source file name, if it contains a public class, must be the same as the public class name itself with a .java extension.
283. Can main method be declared final?
Yes, the main method can be declared final, in addition to being public static.
284. What will be the output of the following statement?
System.out.println ("1" + 3);
It will print 13.
285. What will be the default values of all the elements of an array defined as an instance variable?
If the array is an array of primitive types, then all the elements of the array will be initialized to the default value corresponding to that primitive type. e.g. All the elements of an array of int will be initialized to 0, while that of boolean type will be initialized to false. Whereas if the array is an array of references (of any type), all the elements will be initialized to null.
286. What is an Iterator interface?
The Iterator interface is used to step through the elements of a Collection .
287. What is the GregorianCalendar class?
The GregorianCalendar provides support for traditional Western calendars
288. What is the Locale class?
The Locale class is used to tailor program output to the conventions of a particular geographic, political, or cultural region .
289. What is the SimpleTimeZone class?
The SimpleTimeZone class provides support for a Gregorian calendar .
290. What is the Map interface?
The Map interface replaces the JDK 1.1 Dictionary class and is used associate keys with values.