100% Off Cracking Coding Interview: Java Topic Wise Question 2024

Errors and Exceptions both have a common parent class which is java.lang.Throwable class. ArrayStoreException is thrown when an attempt is made to store the wrong type of object in an array of objects. Recover from exceptions by either using a try-catch block or throwing exceptions back to the caller.

java developer interview questions

Here is an example of a typical recursive function, computing the arithmetic series 1, 2, 3…N. Notice how the addition is performed after the function call. For each recursive step, we add another frame to the stack. Sleep() is a blocking operation that keeps a hold on the monitor / lock of the shared object for the specified number of milliseconds. Compare the sleep() and wait() methods in Java, including when and why you would use one vs. the other. Over the past few years, I have been sharing a lot of Java Interview questions and discussion individually.

Q65. What is a copy constructor in Java?

The logic of sorting must be in the same class whose object you are going to sort. The Iterator can traverse both legacies as well as non-legacy elements. Certain methods of ListIterator are next(), previous(), hasNext(), hasPrevious(), add(E e).

The size of the array is specified during the declaration of the array and it cannot be changed once the array is created. A resizable array implementation in Java is called ArrayList. Dynamically expanding array lists make it possible to add new elements at any time.

1: How can you optimize garbage collection performance in a Java application, especially for large-scale systems?

This approach is ideal for the programs large and complex codes and needs to be actively updated or maintained. A class in Java is a blueprint which includes all your data. A class contains fields (variables) and methods to describe the behavior of an object. Singleton class is a class whose only one instance can be created at any given time, in one JVM.

  • Every time, an object is created using the new keyword, the default constructor of the class is called.
  • As Java is a very popular and vast topic, it contains several questions that could be asked in an interview.
  • Java is called platform independent because of its byte codes which can run on any system irrespective of its underlying operating system.
  • If no constructors are defined for a class, the compiler generates a nullary constructor known as the default constructor.
  • Errors are mostly caused by the environment in which the program is running.
  • Vectors are Recommended for use in a multi-threaded environment.

An array generally contains elements of the primitive data types such as int, float, etc. In such cases, the array directly stores these elements at contiguous memory locations. An java 7 certifications arrayList contains the reference of the objects at different memory locations instead of the object itself. That is why the objects are not stored at contiguous memory locations.

Why does Java not support pointers?

It’s certainly not going to be easy, but by following this roadmap and guide, you are one step closer to becoming a DevOps engineer. So, without wasting any more of your time, here is my list of some of the frequently asked Core Java Interview Questions for beginner programmers. This list focuses on beginners and less experienced devs, like someone with 2 to 3 years of experience in Java.

  • The main objective of the enum is to define user-defined data types.
  • A single teacher can not belong to multiple departments, but if we delete the department teacher object will not destroy.
  • ContextLoaderListener, on the other hand, is the listener to start up and shut down the WebApplicationContext in Spring root.

Primitive and object types in C++ have the same kind of semantics. The primitive and object and classes of Java, on the other hand, are not consistent. C++ distinguishes itself by having features that are similar to procedural and object-oriented languages. The characteristic that sets Java apart is automatic garbage collection.

Add a Comment

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