Java Interview Question

Category Archives: Java Interview Question

How to Compare Two Arrays in Java

Let’s see, How can you compare Two Arrays in Java to verify,  If they are equal to each other or not. Please note you can’t compare a String array to an int array. You can compare the Array only if they have the same data type.   Compare Two Arrays in Java To compare two … Continue reading How to Compare Two Arrays in Java

Find Largest and Smallest Number in Array

Let’s see, How can you find largest and smallest number in Array. Understanding of array data structure is very important for any software developer or Automation Test Engineer. Find smallest and largest number in the Array is one of favorite Interview question in Java Programming. In this program, you need to write a method, which … Continue reading Find Largest and Smallest Number in Array

Bubble Sort in Java

Today we will see, How can you perform Bubble Sort in Java. Bubble sort is sorting algorithm which is used to Sort Array in Java.   Using Bubble sort algorithm we sort an unsorted array by starting from the first element and comparing with an adjacent element. If the first element is greater than later … Continue reading Bubble Sort in Java

Reverse String Program in Java – Java Interview Question

This is common interview question, How to reverse String in Java without inbuilt method. You have inbuilt method to reverse String in Java library, StringBuffer and StringBuilder class with reverse() method which can be used to reverse String in Java.   In this Java tutorial, you will see How to reverse String using StringBuffer, StringBuilder and … Continue reading Reverse String Program in Java – Java Interview Question

How to Remove Space from String in Java

Java String provides several inbuilt methods to remove space from String in Java like trim() method, which removes whitespace from beginning and end.   While using the trim() method, the key thing to remember is that trim() returns a different String object than the older one because String is immutable in Java. On the other … Continue reading How to Remove Space from String in Java

Search Element in Array in Java

Let’s see, How can you Search Element in Array. In Java Programming, sometimes we need to check if a String array contains a particular String or an int array contains a number or not. Java API does not provide any direct method to check element index. We need to use Apache Commons utility class called ArrayUtils. … Continue reading Search Element in Array in Java

20 Core Java Interview Questions for Fresher, 1 to 2 Yrs Exp

1. Which data type you should use to represent currency in Java? Answer – Please tell him/her long or BigDecimal because if you say double, then you need to convince them about rounding and how do you avoid floating point issues. This is one of common mistake we make until they are familiar with the BigDecimal class … Continue reading 20 Core Java Interview Questions for Fresher, 1 to 2 Yrs Exp

Can we create object of Abstract class in Java

This is a very confusing point for many of freshers in Java Programming. Java doesn’t allow to create Object of Abstract Class directly. You can see what is Abstract Class in Java.   Yes, We can create the Object of Abstract Class in Java but not directly. We can create the Object of Abstract Class indirectly with … Continue reading Can we create object of Abstract class in Java