Developer Java Interview Questions

30,911 developer java interview questions shared by candidates

Round 1 : Technical Writter : 1. Write a java program to print numbers from 1 to 10 using 2 threads. Thread 1 should print odd and thread 2 should print Even numbers. 2. Write a program to find duplicate elements in an array In O(n) time using O(1) extra step. 3. A Company is having a number is cyber cafe. Many customer visit cyber cafe and number if computers are limited. If customer don't find available computer then he leave. You have given a function with 2 arguments : 1 number of computers, 1 : a string with pairs. 1st occurrence of alphabet indicate start of customer and second occurrence indicate end. Only 1 person can use a computer at a time. Return count of customers who left cafe without using computer so that company can improve process. example : process(1, ABAB) : should return 1 as only 1 computer is there that is occupied by A when B comes. process(2,ABACBCDD) : should return 0 as all customer A,B,C, D are able to use Cafe. process(3, ABCDCDEFEFA) : should return 2 as D and F could use computer. Round 2 : Technical 1. Internal working of hashmap. 2. How String work in string pool. 3. Difference between String str = "abc" and String str = new String("abc") 4. Some outputs. 5. Complexity for some codes. He wrote code and asked Complexity. 6. You are concern about insert order of element in Map. Which Map you will use? I told LinkedHashMap. then He asked why and why we use thi. Why we don't use HashMap? I explained internal working. 7. why String is immutable? What the need. What do you think, why we need? 8. What is synchronization. Why we use? what to do if i dont want synchronization for some variables. Round 3 : Technical 1. Write a program to reverse a linked list. 2. Write a program to print mirror image of a tree. I printed partial and swaped left subtree and right subtree. He then asked to print full mirror image. rightmost node of right subtree should be leftmost node of left subtree and so on. 3. Some Question on Spring Core, Spring Security. Spring MVC. Dependency Injection, Scope of Singleton Object. 4. Is Spring Singleton object is same as Singleton we create in java. 5. What are the way to create Singleton. I told eager and lazy. He asked to write Code for Thread Safe Singleton. I wrote Lazy Singleton. We then discussed Synchronization on this. 6. Internal of Hashmap and Complexity. 7. What change we should do in custom class if we want to use custom object as key. Hashcode and equals. 8. What is contract between hashcode and equals. Round 4 : MR : Technical :( 1. He asked about 1 of my project. 2. There are some site tiniurl. If you paste any url on their site they will compress it and give you a short link which you can send in emails or post on twitter or facebook. If use click on that url then it redirect you to original site url. How you will implement in your project. We discussion a lot of approach. 3. Given a String oriStr aaaaabcbcdefdefdefghgh and a compressed string cstr a4bc3def3gh2 for prev string. Given a function with 2 arguments cstr and index. print char at this index from oriStr. I told if you have compression algo then you might have decompression algo that should be using reverse engineering. He told ok but I dont want to decompress as i might have billons of alphabets in string. Then I observed cstr and gave solution. He asked to code and it took a lot of time. He gave hint and I was able to write program. It was final round and He asked to wait outside. Later HR came and asked to leave for the day. ! HR told then we wil contact after 2 day. But I could read his face well. Got rejected here. May be l did program but took more time then expected. Hope it will help you.
avatar

Java Developer

Interviewed at MakeMyTrip

4.1
May 31, 2015

Round 1 : Technical Writter : 1. Write a java program to print numbers from 1 to 10 using 2 threads. Thread 1 should print odd and thread 2 should print Even numbers. 2. Write a program to find duplicate elements in an array In O(n) time using O(1) extra step. 3. A Company is having a number is cyber cafe. Many customer visit cyber cafe and number if computers are limited. If customer don't find available computer then he leave. You have given a function with 2 arguments : 1 number of computers, 1 : a string with pairs. 1st occurrence of alphabet indicate start of customer and second occurrence indicate end. Only 1 person can use a computer at a time. Return count of customers who left cafe without using computer so that company can improve process. example : process(1, ABAB) : should return 1 as only 1 computer is there that is occupied by A when B comes. process(2,ABACBCDD) : should return 0 as all customer A,B,C, D are able to use Cafe. process(3, ABCDCDEFEFA) : should return 2 as D and F could use computer. Round 2 : Technical 1. Internal working of hashmap. 2. How String work in string pool. 3. Difference between String str = "abc" and String str = new String("abc") 4. Some outputs. 5. Complexity for some codes. He wrote code and asked Complexity. 6. You are concern about insert order of element in Map. Which Map you will use? I told LinkedHashMap. then He asked why and why we use thi. Why we don't use HashMap? I explained internal working. 7. why String is immutable? What the need. What do you think, why we need? 8. What is synchronization. Why we use? what to do if i dont want synchronization for some variables. Round 3 : Technical 1. Write a program to reverse a linked list. 2. Write a program to print mirror image of a tree. I printed partial and swaped left subtree and right subtree. He then asked to print full mirror image. rightmost node of right subtree should be leftmost node of left subtree and so on. 3. Some Question on Spring Core, Spring Security. Spring MVC. Dependency Injection, Scope of Singleton Object. 4. Is Spring Singleton object is same as Singleton we create in java. 5. What are the way to create Singleton. I told eager and lazy. He asked to write Code for Thread Safe Singleton. I wrote Lazy Singleton. We then discussed Synchronization on this. 6. Internal of Hashmap and Complexity. 7. What change we should do in custom class if we want to use custom object as key. Hashcode and equals. 8. What is contract between hashcode and equals. Round 4 : MR : Technical :( 1. He asked about 1 of my project. 2. There are some site tiniurl. If you paste any url on their site they will compress it and give you a short link which you can send in emails or post on twitter or facebook. If use click on that url then it redirect you to original site url. How you will implement in your project. We discussion a lot of approach. 3. Given a String oriStr aaaaabcbcdefdefdefghgh and a compressed string cstr a4bc3def3gh2 for prev string. Given a function with 2 arguments cstr and index. print char at this index from oriStr. I told if you have compression algo then you might have decompression algo that should be using reverse engineering. He told ok but I dont want to decompress as i might have billons of alphabets in string. Then I observed cstr and gave solution. He asked to code and it took a lot of time. He gave hint and I was able to write program. It was final round and He asked to wait outside. Later HR came and asked to leave for the day. ! HR told then we wil contact after 2 day. But I could read his face well. Got rejected here. May be l did program but took more time then expected. Hope it will help you.

Viewing 3611 - 3620 interview questions

Glassdoor has 30,911 interview questions and reports from Developer java interviews. Prepare for your interview. Get hired. Love your job.