Interview Questions and Answers for 'Booking.com' - 7 question(s) found - Order By Newest Very frequently asked. Favorite question in Walk in Drive of many Indian service companies. Q1. Difference between TreeMap and HashMap ? Core Java
Ans. They are different the way their elements are stored in memory. TreeMap stores the Keys in order whereas HashMap stores the key value pairs randomly. Sample Code for treemap Sample Code for hashmap Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   collections   map   treemap   hashmap   treemap vs hashmap Asked in 31 Companies basic   frequent Try 1 Question(s) TestFrequently asked question for intermediate developers. Frequently asked in HCL Technologies and EPAM. Q2. What is Volatile keyword used for ? Core Java
Ans. Volatile is a declaration that a variable can be accessed by multiple threads and hence shouldnt be cached. Sample Code for volatile Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   oops   synchronization   volatile   java keywords Asked in 42 Companies intermediate   frequent Try 1 Question(s) Test Q3. What is ConcurrentModificationException ? Core Java
Ans. This is the exception that is thrown when we try to modify the non concurrent collection class while iterating through it. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   collections   concurrentmodificationexception   exception  concurrency Asked in 14 Companies intermediate Q4. Write a Program to check if 2 strings are Anagrams ? Core Java
Ans. public void checkIfAnagram(String str1,String str2){
boolean anagram = true;
for(char c:str1.toCharArray()){
if(!str2.contains(String.valueOf(c))){
System.out.println("Strings are Anagrams");
anagram = false;
}
if(anagram == true){
System.out.println("Strings are not Anagrams");
}
}
} Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   check if 2 strings are Anagrams Asked in 30 Companies basic   frequent Q5. How would you do an object oriented design on animals in a zoo ? Design
This question was recently asked at 'Booking.com,InterContinental Hotels,Caissa,Workday'.This question is still unanswered. Can you please provide an answer. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Asked in 4 Companies Q6. Write a method / program that will determine if the parenthesis are balanced in a given string. Core Java
Ans. https://www.geeksforgeeks.org/check-for-balanced-parentheses-in-an-expression/ Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  string  code  coding Asked in 14 Companies Q7. Pascal Triangle Program
Ans. package snippet;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class Pascal {
public static void main(String[] args) {
System.out.println(generatePascalTriangle(5));
}
static Map> generatePascalTriangle(int size) {
Map> triangle = new HashMap<>();
triangle.put(0, Arrays.asList(1));
triangle.put(1, Arrays.asList(1, 1));
for (int i = 2; i <= size; i ) {
List coeffListForI = new ArrayList<>();
List coeffListForI_1 = triangle.get(i - 1);
coeffListForI.add(1);
for (int j = 0; j <= coeffListForI_1.size() - 2; j ) {
coeffListForI.add(coeffListForI_1.get(j) coeffListForI_1.get(j 1));
}
coeffListForI.add(1);
triangle.put(i, coeffListForI);
}
return triangle;
}
} Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Asked in 8 Companies