Top 30 Java Support Interview Questions 2025


1) Which is the superclass of all classes in Java?
The Object class.

The Object class is the superclass of all Java classes (except Object) in Java. It is stored in java. lang package.

2) To check whether the entered string is Palindrome or not?
TestString.java:

import java.util.*;
public class TestString
{
public static void main(String args[])
{
String a, b = “”;
Scanner s = new Scanner(System.in);
System.out.print(“Enter the string : “);
a = s.nextLine();
int n = a.length();
for(int i = n-1; i >= 0; i–)
{
b = b + a.charAt(i);
}
if(a.equalsIgnoreCase(b))
{
System.out.println(“The string is palindrome”);
}
else
{
System.out.println(“The string is not a palindrome”);
}
}
}
Output:

Enter the string : asddsa
The string is palindrome
3) Write a java program to print the total arrangement of any string.
StringArrangements.java:

import java.util.Scanner;
public class StringArrangements {
//Creating a Function to swap the characters of the string
public static String swapString(String a, int i, int j) {
char[] b =a.toCharArray();
char ch;
ch = b[i];
b[i] = b[j];
b[j] = ch;
return String.valueOf(b);
}

public static void main(String[] args)    
{    
    Scanner sc= new Scanner(System.in);  
    System.out.println("Enter String");  
    String str=sc.nextLine();  
    int len =str.length();  
    System.out.println("All the permutations of the string are: ");    
    generatePermutation(str, 0, len);    
}    

//Generating different permutations of the string    
public static void generatePermutation(String str, int start, int end)    
{    
    //Printing the permutations    
    if (start == end-1)    
        System.out.println(str);    
    else    
    {    
        for (int i = start; i < end; i++)    
        {    
            //Swapping the string by fixing a character    
            str = swapString(str,start,i);    
            //Recursively calling function generatePermutation() for rest of the characters     
            generatePermutation(str,start+1,end);    
            //Backtracking and swapping the characters again.    
            str = swapString(str,start,i);    
        }    
    }    
}    

}
Output:

Enter String
ab
All the permutations of the string are:
ab
ba
4) Explain some real-life examples of multithreading.
Multithreading is one of the fascinating features of Java that allows concurrent execution of two or more parts of a program for maximum utilization of CPU.

Some real-life examples of multithreading are as follows:

Listening the music while working on any other application like ms office, web browser, etc.
Gaming is one of the best examples of multithreading; we can use different types of weapons and vehicles in our game. These weapons and vehicles or other elements of the games are nothing but a thread.
Railway ticket reservation system where several customers book tickets at the same time
5) Explain Immutable classes in Java with some examples?
Immutable class means once the object is created, we can not modify its content and state. There are several immutable classes in Java, such as String, Boolean, Byte, Short, Integer, Long, Float, Double, etc.

6) Write a Java program to print a pyramid star pattern?
PyramidStarPattern.java:

public class PyramidStarPattern
{
public static void main(String args[])
{
//i is used for rows and j for columns
//This row will specify the number of rows
int i, j, row = 6;
for (i=0; i1; j–)
{
System.out.print(” “);
}
for (j=0; j<=i; j++ )
{
//prints star
System.out.print(“* “);
}
//It will throw the cursor in a new line after printing each line
System.out.println();
}
}
}
Output:

Java Support Interview Questions
7) How to know whether the linked list is circular or not?
We can check whether the linked list is circular or not. To check it, we will store the header into any other variable, then start traversing the list; if we get the null on the next part of any node, then the linked list is not circular; otherwise we will check the next node is the same as the stored node or not, if so then the link list is circular.

8) Is Java pass by value or pass by ref?
Java is strictly passed by value, not pass by reference. See more.

9) Is Java compiled or interpreted?
The Java source code first compiled into a binary byte code using Java compiler, then this byte code runs on the JVM (Java Virtual Machine), which is a software-based interpreter. So Java is considered as both interpreted and compiled.

10) Write a query to get the required data regarding employees.
SELECT * FROM employees;

11) Does Java support Pointers?
Explicitly Java does not support pointers, but it uses them implicitly. Java uses pointers for the manipulation of object references, but we can not use them externally. The pointer’s usage may lead to illegal access of data because pointers show the exact address of the data, and using this address, any modifications can be made to stored values. So, to improve Java’s security, the concept of the pointer was removed from it.

12) Does Java support multiple inheritance?
Java does not support multiple inheritance instead we can use interfaces to achieve the concept of multiple inheritance. It does not allow multiple inheritance to avoid ambiguity. One of the major examples of ambiguity is the diamond problem that occurs in multiple inheritance.

13) Explain the difference between Path and ClassPath?
The Path is used to define the executables(.exe) files, where the system can find them, whereas the classpath is used to specify the location.

In Java, we define the path variable to set the path for all Java tools like javac.exe, java.exe, javadoc.exe, and so on, and the classpath is used to set the path for Java classes.

14) How do you set the Java_Home environment variable in Linux?
To set up the environment variable in Linux, we need to set up the global config in /etc/profile OR /etc/bash.bashrc file for all users:

vi /etc/profile

Now, follow the below commands:

export PATH=$PATH:/usr/java/jdk1.8./bin
Now, save and close the file. After this, we need to activate the path settings immediately. We can do so by executing the below command:

source /etc/profile

15) What is the full form SQL?
The full form of SQL is Structured Query Language.

16) How to write an HQL query?
String hql = “Your Query Goes Here”;

read more about the HQL query.

17) What is Heap Dump in the Java process, how do you take it?
A heap dump is a snapshot of all the objects available in the memory in the JVM at the moment. The Heap Dumps are useful for troubleshooting the memory-leak problem in Java applications and optimizing the memory. They have usually stored in a binary format hprof files. We can optimize and analyze these files using different tools like JvisualVM, jhat, etc.

18) What is the Thread Dump of Java process, how do you take it?
A Thread dump is a state of all the threads presented in a Java process at the moment. Each thread’s state is available with a stack trace. It is useful for diagnosing thread activity problems. Usually, they are written in plain text, so we can save the data of a thread data in a file and analyze them later. There are different tools available in Java, such as jstack and JMC( Java Mission Control), to take the Thread dump of a process.

19) Explain OutofMemoryError in Java.
OutofMemoryError exception is a memory leak problem in Java. It is thrown when there is insufficient space to allocate an object in the Java heap. In such a scenario, the Java garbage collector cannot make space available to accommodate a new object, and we can not extend the heap further.

20) Explain InvocationTargetException in Java.
InvocationTargetException is a checked exception, which occurs when we invoke a class using the Method.invoke(). It takes place in the java.lang.reflect.InvocationTargetException class.

21) Explain Garbage Collector in Java.
Java Garbage Collection is used to reclaim the unused runtime memory automatically. In Java Garbage Collection, the Garbage stands for unused objects. In other programming languages like C and C++, different functions are used, but, in Java it is performed automatically. Thus, Java provides improved memory management.

22) Explain the difference between JDBC and JNDI
JDBC stands for Java Database Connectivity used to interact with the database. Whereas JNDI stands for Java Naming and Directory Interface, is an API that provides naming and directory functionality to Java applications. A Java application will lookup the JNDI to get access the connection to interact with the database.

23) What is JDBC Connection Pooling?
The JDBC Connection pooling is a technique that is used to create and manage the collection of JDBC connection objects. The main motive of using the Connection pooling is to maintain the connection object and ensure reusability and improve the Java application’s performance.

24) Explain the working of TCP/IP.
The TCP/IP model was developed to provide efficient and accurate data transmission between devices. It breaks a message into several small packets to avoid transmission failure in a long size file. In case it encounters a problem during the transmission, it will start sending the packets again from where they break and reassembles the packets at the destination port. Every route can take a different route to reach the destination. Thus, it provides a secure and uninterrupted data transmission.

Read more about the TCP/ IP protocol.

25) Could you explain the difference between TCP/IP and UDP protocol.?
The TCP/IP stands for Transmission Control Protocol/ Internet Protocol, and the UDP stands for User Datagram Protocol. The TCP/IP is responsible for defining the connection of a system and web connectivity. In comparison, the UDP protocol is a User Datagram Protocol used for broadcasting and multicasting a network transmission.

Some key differences between TCP/IP and UDP protocol are as following:

The Major difference between TCP and UDP is that TCP is a connection-oriented protocol. On the other hand, the UDP is a connectionless protocol.
The UDP is faster than the TCP protocol.
The handshake protocols like SYN, ACK, SYN-ACK are used in TCP, while there is no use of handshake protocols in UDP.
The TCP protocol performs error checking and creates an error recovery; comparatively, the UDP does not perform error checking, and it discards the erroneous packages.
The TCP holds acknowledge segments; comprataively the UDP does not have any acknowledgment segment.
The UDP is lightweight, while the TCP is a heavy-weight protocol.
Read more about TCP vs. UDP.

26) What is Deadlock?
The Deadlock in Java occurs in multithreading. It is a situation when the first thread is waiting for an object lock that is acquired by the second thread, while the second thread is waiting for the object lock that is held by the first thread. Since both threads are at the waiting state for each other thread to release the lock, this condition in Java is known as the Deadlock.

27) If a Java application is running on a server and remotely connected to another Java application, Now, If you don’t have access to that remote host to see if the process is running. How do you find if the server is up and running?
We can use the telnet command to find the server status.

Read more about telnet command.


Comments

Leave a Reply

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