Java developer Interview Questions in United States | Glassdoor.co.in

Java developer Interview Questions in United States

2,236

java developer interview questions shared by candidates

Top Interview Questions

Sort: RelevancePopular Date

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.

17 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.

import java.io.*; public class CountChar { public static void main(String[] args) throws IOException { String ch; BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); System.out.print("Enter the Statement:"); ch=br.readLine(); int count=0,len=0; do { try { char name[]=ch.toCharArray(); len=name.length; count=0; for(int j=0;j=65&&name[0]=97&&name[0]<=123))) count++; } if(count!=0) System.out.println(name[0]+" "+count+" Times"); ch=ch.replace(""+name[0],""); } catch(Exception ex){} } while(len!=1); } }

package epam; import java.util.ArrayList; import java.util.Arrays; import java.util.Scanner; public class RepeatedCharactersInString { public static void main(String[] args) { ArrayList arrli = new ArrayList(); Scanner sc = new Scanner(System.in); String s = sc.next(); String s1=""; for (int i = 0; i < s.length(); i++) { arrli.add(s.charAt(i)); } for (int i = 0; i < arrli.size(); i++) { for (int j = i + 1; j < arrli.size(); j++) { if (arrli.get(i) == arrli.get(j)) { arrli.remove(j); j--; } } } for (int i = 0; i < arrli.size(); i++) { // System.out.println(arrli.get(i)); s1=s1+arrli.get(i); } System.out.println(s1); sc.close(); } }

One or more comments have been removed.
Please see our Community Guidelines or Terms of Service for more information.

They asked me about the Java Object - Oriented, Inheritance and Out-put the single value of the 2 dimension array

7 Answers

Assume there is a method provided getNextperson() which gives Person objects which have comparable interface implemented, now read from a file records and sort it and give first 1000 records, write code on the paper

7 Answers

Given two files that has list of words (one per line), write a program to show the intersection.

6 Answers

public class Person { Person father; Person mother; Gender gender; Integer age; List children; int level = 0; public enum Gender { Male, Female; } } For the above class, you basically have to implement 2 methods. public List getOldestSisters() public List getGreatestAncestors()

5 Answers

What are Exceptions in Java.

7 Answers

what will system.out print do?

4 Answers

A rustic village contains one million married couples and no children. Each couple has exactly one child per year. Each couple wants a girl, but also wants to minimize the number of children they have, so they will continue to have children until they have their first girl. Assume that children are equally likely to be born male or female. Let p(t) be the percentage of children that are female at the end of year t. What is p(t)? "Can't tell" is a potential answer if you don't have sufficient information.

6 Answers

What is inheritance?

4 Answers

On the order of execution of Java code blocks when a class extends another class

4 Answers
110 of 2,236 Interview Questions