Xylem bangalore : Senior Java Developer.

Dated - May 2020

1st Round - HackerRank Test.
Day - I
Question:  Java program for performing the arithmetic addition.

Question:  Java program to implement deep cloning.

Question: Arrange the Words
A Sentence is defined as a string of space separated words that starts with a capital letter followed by lowercase letters and spaces, and ends with a period. That is, it satisfies the regular expression ^[A-Z][a-z]*\.$. Rearrange the words in a sentence while respecting the following conditions.
  1. Each word is ordered by length, ascending.
  2. Words of equal length must appear in the same order as in the original sentence.
  3. The rearranged sentence must be formatted to satisfy the regular expression ^[A-Z][a-z]*\.$
Example 1.
sentence= Cats and hats.

Order the sentence by word's length and keep the original order for the words with same length.
  • Length 3: {and}
  • Length 4: {Cats, hats}
Example 2.
Input: "The lines are printed in reverse order."
Output: "In the are lines order printed reverse."
Length 2: {in}
Length 3: {the, are}
Length 5: {lines, order}
Length 7:{printed, reverse}

public class ArrangeWords {
public static void main(String[] args) {
String sentence = "The lines are printed in reverse order.";
StringBuilder sb = new StringBuilder();
String input = sentence.substring(0, sentence.length()-1); 
LinkedHashMap<String, Integer> hm = new LinkedHashMap<String, Integer>();
    for(String word : input.toLowerCase().split(" ")){
        hm.put(word, word.length()); 
    .sorted(Map.Entry.<String, Integer>comparingByValue()) 
    sb.append(e.getKey() + " ");  
String result = sb.substring(0, 1).toUpperCase() + sb.substring(1).trim() + ".";
Input: The lines are printed in reverse order.
Output: In the are lines order printed reverse.

Question : String Manipulation
Given a String , print the last character and second last character separated with space.
Input : APPLE
Output : E L

public static String lastletters(String word){
    //Write you code here
    int len=str.length();
    char last=word.charAt(len-1);
    char secondlast=word.charAt(len-2);
    return Character.toString(last)+" "+Character.toString(secondlast);
Input : APPLE
Output : E L

All available test cases passed.

2nd Round - Technical.
Mode - Zoom Video & Collabedit for coding.
Interviewer - Harish Kumar.
Day - I+6

1. First I would like to introduce myself, I am director ....... and I handle all the stuffs of this project and I am aware about complete SDLC and Development, so I am kind of Technical as well.
2. What are the challenges you have faced in your work?
3. Sent a link on Zoom for Collabedit for coding round.
//input array = [U1,U2 U3,U4 U2,U1 , U1,U5]
//output = [U1,U2 , U1,U5 , U3,U4]
//overalll sorted output with 0th index;distinct pair
package xylem;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedHashSet;
import java.util.List;
public class Test {
public static void main(String[] args) {
ArrayList list=new ArrayList();
public static List<String> getSortedUserSet(List<String> userArray){
Collections.sort(userArray);//U1,U2  U1,U5  U2,U1  U3,U4
LinkedHashSet<String> set=new LinkedHashSet<>();
for(String usernameSet : userArray){
String str[]=usernameSet.split(",");
Arrays.sort(str);//U1,U2(3rd pair)
String strPair=str[0]+","+str[1];
ArrayList list=new ArrayList();
for(String str: set){
return list;

Output : 
[U1,U2, U1,U5, U3,U5]

4. Are you aware about memory management? What is Garbage Collection and How does it work internally? What is System.gc? Can we force jvm to call garbage collector?
5. What is static and where does it get allocated, what are it's usage?
6. What is memory leakage? 
7. What's the benefit of connection pooling?
8. How HashSet works internally? Explain two level verification as well, How does it work?
9. We have overridden HashCode where it returns static value let's say 123, what will be the problem in peformance while adding the elements in HashMap?
10. What Multithreading platform you worked on?


Popular posts from this blog

Java Coding Interview Questions with Answers

Zensar Java Interview Questions.