Java Developer Interview Questions in United States

Java Developer Interview Questions in United States

In your interview for a java developer position, be prepared to answer technical questions that test your understanding of Java basics. Interviewers may also ask open-ended questions to assess your coding and problem-solving abilities. Prepare for non-technical questions that focus on time management, interpersonal communication, and work ethic.

20,918 Java Developer interview questions shared by candidates

Top Java Developer Interview Questions & How to Answer

Here are three java developer interview questions and how to answer them:

Question #1: What is the difference between HashTable and HashMap in Java?

How to answer: Interviewers use technical questions to assess your formal training and understanding of the Java programming language. Use your answer to demonstrate your communication skills. Even if you have been coding for some time, it can be helpful to review Java basics before your interview.

Question #2: Write a program to determine if 243 is an Armstrong number.

How to answer: Interviewers use open-ended questions to test your coding skills. This question allows the employer to assess your ability to solve a problem using a Java algorithm. Explain your thinking process as you use a code editor or whiteboard to solve the problem.

Question #3: How do you produce quality code when you have several Java projects to complete at once?

How to answer: Java developers often juggle multiple projects at the same time. Interviewers use questions such as this to test your time management and organizational skills. Employers are also trying to assess your commitment to quality work. If you have experience as a developer, include examples from your work history that demonstrate high-quality work and effective time management.

Top Interview Questions

Sort: Relevance|Popular|Date
Naaptol
Junior Java Developer was asked...January 10, 2018

attributes of <tr> tag

41 Answers

please let me know if anyone got Job

36. If you get call then follow this interview experience

How many of you waiting after 3rd round

Show More Responses
EPAM Systems

Coding test: 1. Given a string, find out if there's repeat characters in it. 2. SQL. Given a Customer table and a Payment table (with Customer ID as primary and foreign key), write a query to output a list of customers who have not paid their bills in the last 3 months.

15 Answers

Did well on the first Java coding test. Solution using Hashset. Not so well on the SQL query. Able to give a query, but a few errors in it I am sure. Also there was a second questions regarding the SQL query, which we didn't have time to get to. So that was another bad thing. I am pretty sure I did not pass. But good learning experience. Less

import java.util.*; public class test { public static void main(String[] args) { String str = "abdc"; char[] arr = str.toCharArray(); HashSet set = new HashSet(); for (char i : arr ) { set.add(i); } if((set.size()) == (arr.length)) System.out.println("unique character"); else System.out.println("repetition"); } } Less

No

Show More Responses
Oracle

Write a program to print * * * * * * * * * * * * * * * * * * * * * * * * * * * * * with minimum number of variable use

12 Answers

class StarPrint { public static void main (String[] args) throws java.lang.Exception { int i = 0, j = 0; for( i = 5; i &gt; 0; i-- ){ for( j = 0; j &lt; 5 - i; j++) System.out.print(" "); for( j = 0; j &lt; i; j++ ) System.out.print("* "); System.out.println();} for( i = 3; i &lt;= 6; i++ ){ for( j = 0; j &lt;= 5 - i; j++) System.out.print(" "); for( j = 1; j &lt; i; j++ ) System.out.print("* "); System.out.println(); } } } Less

public class Check { public static void main(String[] args) { int limit = 5; // Specify the number of lines as limit and check output int i=0,j=0; for(i=0;ilimit-i;j--)System.out.print(" "); for(j=limit;j&gt;i;j--)System.out.print("* "); System.out.println(); } j=limit; for(;limit&gt;1;limit--){ for(i=2;ilimit-2;i--)System.out.print("* "); System.out.println(); } } } Less

In the previous solution, the LESS THAN and GREATER THAN symbols have nit been parsed. public class Check { public static void main(String[] args) { int limit = 9; int i=0,j=0; for(i=0;i limit-i;j--)System.out.print(" "); for(j=limit;j &gt; i;j--)System.out.print("* "); System.out.println(); } j=limit; for(;limit &gt; 1;limit--){ for(i=2;i limit-2;i--)System.out.print("* "); System.out.println(); } } } Less

Show More Responses
WebKul

Write a program for odd input the pattern output will as below n=1 *-* n=3 ***** *** *---* *** *****

12 Answers

import java.util.Scanner; public class Pattern{ public static void main(String[] args) { Scanner sc=new Scanner(System.in); int n=sc.nextInt(); for(int i=n;i&gt;=2;i--){ for(int j=1;j&lt;=2*n-(i-1);j++){ System.out.print(" "); } for(int k=1;k&lt;=2*i-1;k++){ System.out.print("*"); } System.out.println(); } for(int i=1;i&lt;=n-1;i++){ System.out.print(" "); } System.out.print("*"); for(int i=1;i&lt;=n;i++){ System.out.print("-"); } System.out.print("*"); System.out.println(); for(int i=2;i&lt;=n;i++){ for(int j=1;j&lt;=n-i;j++){ System.out.print(" "); } for(int k=1;k&lt;=2*i-1;k++){ System.out.print("*"); } System.out.println(); } } } Less

import java.util.Scanner; class New3 { public static void main(String ... args) { Scanner sc =new Scanner(System.in); int n=sc.nextInt(); for(int j=n,p=1;j&gt;=2;j--,p++) { for(int i=1;i&lt;=n+p;i++) System.out.print(" "); for(int k=1;k&lt;=2*j-1;k++) System.out.print("*"); System.out.println(""); } for(int i=1;i&lt;=n-1;i++) System.out.print(" "); System.out.print("*"); for(int i=1;i&lt;=n;i++) System.out.print("-"); System.out.print("*"); System.out.println(""); int q=n-2; for(int j=2;j&lt;=n;j++) { for(int i=1;i&lt;=q;i++) System.out.print(" "); q--; for(int k=1;k&lt;=2*j-1;k++) System.out.print("*"); System.out.println(""); } } } Less

import java.util.Scanner; public class webu { public static void main(String[] args) { Scanner sc=new Scanner(System.in); System.out.println("enter the no"); int n=sc.nextInt(); for (int i = n; i &gt;1; i--) { for(int j=1;j1){ for (int l =1 ; l &lt;=2*i-1; l++) { System.out.print("*"); } System.out.println(" "); } } } } Less

Show More Responses
Naaptol

written test on basic java you can crack if you are average concept in java.

10 Answers

But what is the need of exam no result came 2 months have passed i suggest never go and waste your time. Less

you are right . I have never seen any interview experience that got job offer . at every end of year they have walkin drive . Thats look suspicious . At everytime when you go for interview they ask for reference. It might be true that they hire people who have strong refrence Less

Yes I got call. May be they call only those people who cracks Aptitude They may have high cut off. Less

Show More Responses
Mobicule

If you add an element at a[1] position in arreylist and access a[2] element,what will happen?

9 Answers

Let arraylist contains {5,6,4,3,1} If you add 2 at 0th position then arraylist become {2,5,6,4,3,1} So according to question you will get old element of a[1] at a[2]'s position Less

We will get runtime exception:ArrayIndexOutOfBoundException

Let arraylist contains {5,6,4,3,1} If you add 2 at 0th position then arraylist become {2,5,6,4,3,1} So according to question you will get old element of a[1] at a[2]'s position Less

Show More Responses
Atlassian

A company uses a format to exchange messages with us. You need to validate the input. The character encoding ASCII. Valid characters are between 0x20 (space) and 0x7E (~). write validate function to generate valid output or the error message.

9 Answers

public static void printValidMassage(){ String msg="204a6176617e"; String msg1=convertHextoChars(msg); boolean isValid=(msg1.startsWith(" ") &amp;&amp; msg1.endsWith("~")) ? true : false; } private static String convertHextoChars(String hex) { StringBuffer sb = new StringBuffer(); for (int i=0; i Less

public static void printValidMassage(){ String msg="204a6176617e"; String msg1=convertHextoChars(msg); boolean isValid=(msg1.startsWith(" ") &amp;&amp; msg1.endsWith("~")) ? true : false; System.out.println(isValid); } private static String convertHextoChars(String hex) { StringBuffer sb = new StringBuffer(); for (int i=0; i Less

for (int i=0; i

Show More Responses
WebKul

take input from user...3,5,7 etc and draw a pattern if input is 3 then *** *** * * *** * * * if input is 5 then ***** ***** * * * * * * ***** * * * * *

9 Answers

code for c language #include #include int main() {int n=7,i,j,l,k,m; for(i=1;i&lt;=n;i++) printf("*"); printf(" "); for(i=1;i&lt;=n;i++) printf("*"); printf("\n"); for(j=1;j&lt;=n-2;j++) { for(k=1;k&lt;=n-1;k++) printf(" "); printf("*"); printf(" "); printf("*"); printf("\n"); } for(i=1;i&lt;=n-1;i++) printf(" "); for(i=1;i&lt;=n;i++){ printf("*");} printf("\n"); for(i=1;i&lt;=n;i++) { for(j=1;j&lt;=n;j++) printf(" "); printf("*"); printf("\n"); } return 0; } Less

/* if input is 3 then *** *** * * *** * * * if input is 5 then ***** ***** * * * * * * ***** * * * * * */ import java.util.Scanner; public class Pattern3 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n=sc.nextInt(); for(int i=1; i&lt;=2; i++){ for(int j=1; j&lt;=n; j++){ System.out.print("*"); }System.out.print(" "); }System.out.println(); for(int i=1; i&lt;=n-2; i++){ for(int j=1; j&lt;=n-1; j++){ System.out.print(" "); }System.out.println("* *"); } for(int i=1; i&lt;=(n+1)/2; i++){ System.out.print(" "); } for(int i=1; i&lt;=n; i++){ System.out.print("*"); }System.out.println(); for(int i=1; i&lt;=n; i++){ for(int j=1; j&lt;=n; j++){ System.out.print(" "); }System.out.println("*"); } sc.close(); } } Less

check this import java.util.Scanner; public class MyClass { public static void main(String args[]) { Scanner sc =new Scanner(System.in); int n=sc.nextInt(); for(int i=0;i&lt;2;i++){ for(int j=0;j Less

Show More Responses
WebKul

The first question was to print pattern that is n=1 *** n=3 * * *** *** ************ *** *** * * n=5 * * *** *** ***** ***** ******************* ***** ***** *** *** * *

9 Answers

I don't understand the logic of mid line.... import java.util.Scanner; /* 1 *** 3 * * *** *** ************ *** *** * * 5 * * *** *** ***** ***** ******************* ***** ***** *** *** * * */ public class Pattern1 { public static void main(String[] args) { Scanner sc =new Scanner(System.in); int n=sc.nextInt(); if(n&gt;1){ for(int i=1; i1){ for(int i=(n+1)/2; i&gt;=1; i--){ for(int j=1; j&lt;=(((n+1))/2)+1-i; j++){ System.out.print(" "); } int k=0; while(k != (2*i)-1){ System.out.print("*"); k++; }k=0; System.out.print(" "); while(k!=(2*i-1)){ System.out.print("*"); k++; }k=0; System.out.println(); } } sc.close(); } } Less

import java.util.Scanner; /* 1 *** 3 * * *** *** ************ *** *** * * 5 * * *** *** ***** ***** ******************* ***** ***** *** *** * * */ public class Pattern1 { public static void main(String[] args) { Scanner sc =new Scanner(System.in); int n=sc.nextInt(); if(n&gt;1){ for(int i=1; i1){ for(int i=(n+1)/2; i&gt;=1; i--){ for(int j=1; j&lt;=(((n+1))/2)+1-i; j++){ System.out.print(" "); } int k=0; while(k != (2*i)-1){ System.out.print("*"); k++; }k=0; System.out.print(" "); while(k!=(2*i-1)){ System.out.print("*"); k++; }k=0; System.out.println(); } } sc.close(); } } Less

package pattern; import java.util.Scanner; public class webu1 { public static void main(String[] args) { Scanner sc=new Scanner(System.in); System.out.println("enter the no"); int n=sc.nextInt(); for(int i=1;i=1; i--) { for (int j = 0; j &lt; n-i; j++) { System.out.print(" "); } for(int k=0;k&lt;(2*i-1);k++){ System.out.print("*"); } System.out.print(" "); for(int k=0;k&lt;(2*i-1);k++){ System.out.print("*"); } System.out.println(""); } } } Less

Show More Responses
IHS Markit

How would you measure 4 litres of water if you have 3 litre and 5 litre canisters?

8 Answers

1) Pour water in 5 litre container 2) Pour 5 litre container into 3 litre until full. You are left with 2 litre in 5 litre container 3) Empty 3 liter container. Pour 2 litre into 3 litre container 4) Fill 5 litre container until full 5) Pour 1 litre into 3 litre container until full. Left with 4 litres in 5 litre container. Less

Add 2 full measures using the 5l, remove 2 full measures with the 3l, you are left with 4l. Less

Fill full water in the 5 litre canister, remove 3 liters of it to the 5 litre to the 3 litre canister. Keep remaining in the 5 litre canister(=2 litre) somwhere. Take another 5 litre water and perform the same procedure.= another 2 litre... 2+2 =4 litre.. done. Less

Show More Responses
Viewing 1 - 10 of 20,918 interview questions

See Interview Questions for Similar Jobs

Glassdoor has 20,918 interview questions and reports from Java developer interviews in United States. Prepare for your interview. Get hired. Love your job.