Java

50+ Core Java Questions and Answers for Technical Interview Preparation

Here are the 50+ Core Java Questions and Answers for Technical Interview Preparation.

The following list presents core java questions and answers. Nevertheless, it will help you prepare for any technical interview. Moreover, Java is one of the most popular languages in the developers’ community. So you must have command in Java while preparing for a technical interview.

  1. What is JDK? Answer. Basically, JDK or Java Development Kit is the essential tool for developing java based applications. Further, JDK is comprises tools and libraries along with JRE (Java Runtime Environment).
  2. What is JRE? Answer. In order to run a Java program, we need JRE (Java Runtime Environment). In fact, JRE comprises JVM (Java Virtual Machine) and library classes.
  3. What is a ClassLoader? Answer. In order to load a class file in JVM, the ClassLoader component of Java Architecture is used. In other words, ClassLoader takes the bytecode (.class file) as input and loads it into the JVM. Further, the purpose of the bootstrap class loader is to load the programmer-defined classes as well as Java API classes.

Continue Reading ….

  1. What is JIT Compiler? Answer. For the purpose of converting the bytecode into native code, the JVM uses JIT (Just in Time) compiler.
  2. What is an Adaptive Optimizer? Answer. Basically, Adaptive Optimizer is one of the components in Java Architecture. Also, it identifies the heavily used areas. Further, the JVM compiles these heavily used pieces of code. While, rest of the code is interpreted and executed as usual.
  3. What is Byte Code Verifier? Answer. For the purpose of verifying the validity of the bytecode, the JVM uses Byte Code Verifier. So, the Verifier applies several checks such as variable initialization, type validity, access rule violation, and so on. However, it is also possible to disable these checks. Therefore, Bytecode verifier ensures that the code doesn’t violate the JVM’s security restrictions.

Continue Reading …..

  1. How does Java achieve Platform Independence? Answer. Since the class file contains bytecode, a Java program is platform independent. Because the bytecode has the ability to run on any platform. This is because a class file is compiled to a target JVM and remains independent to the underlying platform.
  2. How to access Command Line Arguments in Java? Answer. In order to access command line arguments in Java, you can use the main method which takes an array of strings as arguments. Actually, the elements in the array represent the arguments passed to the program. For example. public static void main(String[] args) { for (String arg : args) { System.out.println(arg); } }
  3. What is the use of the PATH variable? Answer.
  4. What is the use of the CLASSPATH variable? When should we use it?
  5. When and how do you assign values to the PATH variable and CLASSPATH variable?
  6. What are all the characteristic features of the Java programming language?
  7. What are the data types in Java and what are their sizes?
  8. When and how do you declare an array in Java?
  9. How do you find the length of an array in java?
  10. What are the components in Java Architecture? Answer. Basically, the Java Architecture comprises compile-time environment and runtime environment. While the compietime environment has java compiler that converts java source code into bytecode. However runtime environment comprises java class libraries, class loader, and JVM.
Core Java Questions and Answers - Java Architecture
Core Java Questions and Answers – Java Architecture

Tricky Core Java Questions and Answers

  1. What is the difference between final, finally and finalize in Java? Answer.
  2. Can you explain the concepts of inheritance and polymorphism in Java? Answer.
  3. What is the difference between checked and unchecked exceptions in Java? Answer.
  4. Can you explain the difference between static and dynamic binding in Java? Answer.
  5. What is the difference between String, StringBuilder, and StringBuffer in Java? Answer.
  6. Can you explain the difference between method overloading and method overriding in Java? Answer.
  7. What is the use of the transient keyword in Java? Answer.
  8. Can you explain the difference between continue and break statements in Java?
  9. What is the use of the default keyword in switch statements in Java?
  10. Can you explain the difference between super and this keywords in Java?

Core Java Questions and Answers on Collections

  1. What is the difference between ArrayList and LinkedList in Java?
  2. When and how to use HashMap in Java?
  3. What is the difference between HashMap and HashTable?
  4. Discuss the difference between Iterator and ListIterator in Java?
  5. When and how to use the ConcurrentHashMap in Java?
  6. What is the difference between Set and List in Java Collections?
  7. How does TreeSet maintain the order of elements?
  8. When and how to use the NavigableSet in Java?
  9. What is the use of WeakHashMap in Java?
  10. How does PriorityQueue works in Java Collections Framework?

Core Java Questions and Answers on Swing Library

  1. What is the purpose of using Java Swing in GUI development?
  2. When and how should we create a simple Java Swing application?
  3. How does Java Swing handle event handling compared to AWT?
  4. Can you explain the concept of layout managers in Java Swing?
  5. What is the difference between a JFrame and a JDialog in Java Swing?
  6. When should we consider creating a custom component in Java Swing?
  7. How does Java Swing support the customization of look and feel?
  8. Can you explain the use of the TableModel interface in Java Swing?
  9. What is the role of the RepaintManager in Java Swing?
  10. When and how should we use the Drag and Drop feature in Java Swing?

Core Java Questions and Answers on Multithreading

  1. What is multithreading in Java?
  2. Can you explain the difference between a process and a thread?
  3. When and how should we use the java.util.concurrent package in multithreading?
  4. Can you give an example of using the java.util.concurrent.Executor framework?
  5. How does the synchronized keyword work in Java?
  6. What is the use of wait() and notify() methods in Java?
  7. Can you explain the concept of deadlocks in Java?
  8. What is the difference between a deadlock and a livelock?
  9. Can you give an example of using the java.util.concurrent.locks package in Java?
  10. Can you explain the use of the java.util.concurrent.atomic package in Java?

Graphics in Java

  1. What is Java Graphics and how does it differ from AWT and Swing?
  2. When and how should we use the java.awt.Graphics class to draw shapes?
  3. How does the java.awt.Graphics2D class differ from the java.awt.Graphics class?
  4. What is the role of the java.awt.Color class in Java Graphics?
  5. When and how should we use the java.awt.Paint interface to fill shapes with color or pattern?
  6. What is the use of the java.awt.Stroke interface in Java Graphics?
  7. Can you explain the concept of the Java 2D API?
  8. How does the java.awt.Font class work in Java Graphics?
  9. When and how should we use the java.awt.RenderingHints class to enhance the quality of graphics in Java?
  10. Can you explain the concept of the java.awt.AlphaComposite class in Java Graphics?

Further Reading

Java Practice Exercise

programmingempire

Princites

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *