Interview Question

Lead Java Developer Interview

-New York, NY

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.

AnswerAdd Tags

Interview Answers

15 Answers

19

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.

Anonymous on

9

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"); } }

Anonymous on

2

No

Prachi Jha on

3

SQL: select a.customer_name from Customer a left join Payments p on p.cid =a.cid where DATEDIFF(day,p.lastPaymentDate,getdate())>90;

Abhay on

0

No

Mohd Yusuf on

0

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); } }

1. Given a string, find out if there's repeat characters in it on

0

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(); } }

To find out repeated characters in a given string on

0

SQL> select customername from customers inner join Payment on customers.customer id=Payment.customerid where payment.due>=3

query to output a list of customers who have not paid their bills in the last 3 months. on

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(); ArrayList arrli2 = 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

To find out repeated characters in a given string on

1

String res=""; for(int i=0;i

Vrinda on

0

Coding test: 1. Given a string, find out if there's repeat characters in it. public static void findRepeatedCharacters(String input) { String normalized = (input.toLowerCase()).trim(); char[] inputCharArray = normalized.toCharArray(); int index = 1; String searchStr = ""; String repatedChars = ""; for (char c : inputCharArray) { searchStr = normalized.substring(index); if (searchStr.contains(Character.toString(c))) { if (!repatedChars.contains(Character.toString(c))) { repatedChars = repatedChars + Character.toString(c); } } index = index + 1; } if (repatedChars.length() > 0) { System.out.println("Repeated characters in the input string '" + normalized + "' are : " + repatedChars); } else { System.out.println("There are no repated characters in the input string '" + normalized); } }

Bilal Ahmed on

0

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. Solution : Select * from customer where customer.customerid NOT IN (SELECT payment.customerid FROM payment where paymentdate >= DATE_SUB(CURDATE(), INTERVAL 3 MONTH));

Bilal Ahmed on

4

public class Test { public static void main(String args[]) { String test = "abcddeff"; ArrayList listStr = new ArrayList(); for (int i =0; i< test.length(); i++) { if (listStr.contains(test.charAt(i))) { System.out.println("Repeated Character Found:"+test.charAt(i)); } else { listStr.add(test.charAt(i)); } } } } ----To find out repeated characters in a given string

Vigna on

2

import java.util.*; public class FindDuplicates{ public static void main(String []args){ String test = "abccdefga"; char[] arr = test.toCharArray(); List list = new ArrayList(); for(int i=0; i

Shyam H on

3

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(); ArrayList arrli2 = 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

To find out repeated characters in a given string on

Add Answers or Comments

To comment on this, Sign In or Sign Up.