Skip to content

Top 57 Technical Java Interview Questions & Answers 2024

  • by

Child object does not have their lifecycle and if parent object deletes all child object will also be deleted. Let’s take again an example of a relationship between House and rooms. House can contain multiple rooms there is no independent life of room and any room can not belongs to two different houses if we delete the house room will automatically delete. An aggregation is a specialized form of Association where all object has their own lifecycle but there is ownership and child object can not belong to another parent object.

To achieve this, Java provides a method clone() to make use of this functionality. This method creates a new instance of the class of the current object and then initializes all java 7 certifications its fields with the exact same contents of corresponding fields. To object clone(), the marker interface java.lang.Cloneable must be implemented to avoid any runtime exceptions.

Can you make a constructor final?

Exception propagation is a process in which the exception is dropped from to the top to the bottom of the stack. If not caught once, the exception again drops down to the previous method, and so on until it gets caught or until it reaches the very bottom of the call stack. Recover from exceptions by either using a try-catch block or throwing exceptions back to the caller. A FailSafe iterator does not throw a ConcurrentModificationException if the underlying collection is modified while the iterator is being used. Alternatively, it creates a snapshot of the collection at the time the iterator is created and iterates over the snapshot. For example, the iterator for a ConcurrentHashMap is FailSafe.

The StringBuffer class in Java is identical to the String class except that it is changeable. We can declare the main method without using static and without getting any errors. But, the main method will not be treated as the entry point to the application or the program. In this article, we will provide 200+ Core Java Interview Questions tailored for both freshers and experienced professionals with 3, 5, and 8 years of experience.

Relatable Rites of Passage All New Developers Go Through

The map allows a single null key at most and any number of null values. Iterator helps in iterating over a collection of elements sequentially. Iterable provides a way to iterate over a sequence of elements.

  • These variables are declared within a class, but outside a method.
  • In a program, if some code within a method throws a checked exception, then the method must either handle the exception or must specify the exception using the throws keyword.
  • JspDestry() method is invoked from javax.servlet.jsp.JspPage interface whenever a JSP page is about to be destroyed.
  • It can also be returned from the method as the current class instance.

The inner class has a reference to the enclosing outer class, generally using the ‘this’ pointer. It is used to do both creation and initialization in a single statement. When you create a subclass instance, you’re also creating an instance of the parent class, which is referenced to by the super reference variable. In Java, the super keyword is a reference variable that refers to an immediate parent class object. Java is not 100% Object-oriented because it makes use of eight primitive data types such as boolean, byte, char, int, float, double, long, short which are not objects.

Leave a Reply

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