Java Interview Questions & Answers

Showing 10 of 301 questions | Page 7

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

61. What is an Iterator?

Some of the collection classes provide traversal of their contents via a java.util.Iterator interface. This interface allows you to walk through a collection of objects, operating on each object in turn. Remember when using Iterators that they contain a snapshot of the collection at the time the Iterator was obtained; generally it is not advisable to modify the collection itself while traversing an Iterator.

62. What is daemon thread and which method is used to create the daemon thread?

Daemon thread is a low priority thread which runs intermittently in the back ground doing the garbage collection operation for the java runtime system. setDaemon method is used to create a daemon thread.

63. What is Externalizable interface?

Externalizable is an interface which contains two methods readExternal and writeExternal. These methods give you a control over the serialization mechanism. Thus if your class implements this interface, you can customize the serialization process by implementing these methods.

64. What is Externalizable?

Externalizable is an Interface that extends Serializable Interface. And sends data into Streams in Compressed Format. It has two methods, writeExternal(ObjectOuput out) and readExternal(ObjectInput in)

65. What is final?

A final class can't be extended ie., final class may not be subclassed. A final method can't be overridden when its class is inherited. You can't change value of a final variable (is a constant).

66. What is HashMap and Map?

Map is Interface and Hashmap is class that implements that.

67. What is Overriding?

When a class defines a method using the same name, return type, and arguments as a method in its superclass, the method in the class overrides the method in the superclass. When the method is invoked for an object of the class, it is the new definition of the method that is called, and not the method definition from superclass. Methods may be overridden to be more public, not more private.

68. What is serialization?

Serialization is a mechanism by which you can save the state of an object by converting it to a byte stream.

69. What is static in java?

Static means one per class, not one for each object no matter how many instance of a class might exist. This means that you can use them without creating an instance of a class.Static methods are implicitly final, because overriding is done based on the type of the object, and static methods are attached to a class, not an object. A static method in a superclass can be shadowed by another static method in a subclass, as long as the original method was not declared final. However, you can't override a static method with a nonstatic method. In other words, you can't change a static method into an instance method in a subclass.

70. What is synchronization and why is it important?

With respect to multithreading, synchronization is the capability to control the access of multiple threads to shared resources. Without synchronization, it is possible for one thread to modify a shared object while another thread is in the process of using or updating that object's value. This often leads to significant errors.
Questions and Answers for Competitive Exams Various Entrance Test