Senior Java Engineer Interviews

Senior Java Engineer Interview Questions

4K

Senior Java Engineer interview questions shared by candidates

Top Interview Questions

Sort: Relevance|Popular|Date
Senior Java Developer was asked...November 18, 2010

How would you scale access to a system like Twitter

3 Answers

I was thinking geographically distributed servers.

Cf

There's probably no real correct answer, though the solutions go from common to esoteric in a pretty normal progression: caching, shared-cache like memcache, optimize usage, prefetch, then get creative. This is more about testing reasoning and how far you'll go to solve a problem. Less

N2N Global

Q: Why multiple inheritances are not supported in Java?

1 Answers

Because of diamond pattern, diamond pattern creates ambiguity and make problem for compiler. Anyway java supports multiple inheritances via interfaces. I think more convincing reason for not supporting multiple inheritance is complexity involved in constructor chaining, casting etc rather than diamond. Less

BzzAgent

If you were responsible for development and launch of a billing system, how would you handle a critical situation?

1 Answers

My answer: 1. Pause or isolate the problematic process/workflow if possible 2. Study the logs and relevant data 3. Try to reproduce locally (in a sandbox) 4. Try to reproduce in staging environment 5. Add and deploy fix, enable the process/workflow back 6. Follow up with affected customers via support Less

American Express

How many credit cards does Amex issue in a year in US?

11 Answers

Do you remember what type of questions they asked in online coding screen sharing ? I have an interview on next tuesday and i am nervous about typing code in a text editor . Can you give me some sample questions they asked ? Less

These were fairly straight forward ones- FizzBuzz, Fibonacci for coding problems, couple of bitwise operations with XOR, regex for US phone number, abt 50% theory questions like interface vs abstract classes and uses of generics and SOLID principles. One question were I messed up a bit was 'Write the api for System.out.println()'. I didn't fully understand the question, then the interviewer clarified. Essentially, he wanted me to write the classes and methods (ignoring the actual logic code) that would allow the user to write System.out.println(). I used inner class to implement it. Good luck. Less

Thanks. I was contacted by the Sr.Director about 10 days after the interview and made the offer. Less

Show More Responses
Atlassian

A company uses a format to exchange messages with us. You need to validate the input. The character encoding ASCII. Valid characters are between 0x20 (space) and 0x7E (~). write validate function to generate valid output or the error message.

9 Answers

public static void printValidMassage(){ String msg="204a6176617e"; String msg1=convertHextoChars(msg); boolean isValid=(msg1.startsWith(" ") && msg1.endsWith("~")) ? true : false; } private static String convertHextoChars(String hex) { StringBuffer sb = new StringBuffer(); for (int i=0; i Less

public static void printValidMassage(){ String msg="204a6176617e"; String msg1=convertHextoChars(msg); boolean isValid=(msg1.startsWith(" ") && msg1.endsWith("~")) ? true : false; System.out.println(isValid); } private static String convertHextoChars(String hex) { StringBuffer sb = new StringBuffer(); for (int i=0; i Less

for (int i=0; i

Show More Responses
Morgan Stanley

Core Java questions & this person was also not aware about the immutability concept properly except what is given on internet. I had to teach him the immutability of class & object, else for this person both are same.

6 Answers

Many companies are doing the same either companies are just giving illusion to people that they are hiring or the incompetent interviewers are not selecting any worthy candidate for the safety of their own job. In short, all seems to be a kind of fraud going on in name of hiring. Less

I had the same experience. I was supposed to be interviewed by some Morgan Stanley person on 16th April 2020, then this Morgan Stanley person called me to reschedule the call. Then in evening, this person never showed his face in video conference & he also didn't seem to have proper technical understanding. I think his name was 'Dhaval' & I don't feel that he will select any person more capable. Less

I also had the similar experience, I think either stupid people work here or stupid people come to take the interviews. Less

Show More Responses
Veeva Systems

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

5 Answers

/** * Returns the Persons which are the greatest number of levels up the family tree * from this instance. Examples: * Given a tree where this person instance only has a mother and father, return mother and father. * Given a tree where this person instance has a mother &amp; father, and a grandfather on the mother's side, return only the grandfather on the mother's side. * @return List of Person */ public List getGreatestAncestors() { // If this is the root of the tree, return empty array because there is no ancestor for the tree if (this.father == null &amp;&amp; this.mother == null) { return new ArrayList(); } List fList = new ArrayList(); List mList = new ArrayList(); if (this.father != null) { fList = this.father.getGreatestAncestors(); } if (this.mother != null) { mList = this.mother.getGreatestAncestors(); } List results = new ArrayList(); for (Person p : fList) { if (results.contains(p)){ continue; } results.add(p); } for (Person p : mList) { if (results.contains(p)){ continue; } results.add(p); } return results; } Less

I cranked this out in about 30 minutes. I believe it works quite well. I've also included the corresponding unit tests: file: Person.java ------------------------------------------------------------------------------------------------------------- package Command; import java.util.ArrayList; import java.util.HashSet; import java.util.List; public class Person { Person father; Person mother; Gender gender; Integer age; List children; int level = 0; public enum Gender { Male, Female; } Person(Person dad, Person mom, Gender gender, int age, int level) { this.father = dad; this.mother = mom; this.gender = gender; this.age = age; this.level = level; } public void setChildren(List children) { this.children = children; } public void addChild(Person child) { this.children.add(child); } public List getOldestSisters () { // given the current person (self), determine parents // then get children of those parents // Determine gender of each child // Where they are female, get ages // return females with age &gt; mine // Note: must check on both sides father/mother as there may be a mixed marriage // Combine list of children - Exclude YOU as you cannot be your own sister. // Use a set to eliminate duplicates. HashSet allChildren = new HashSet(); // Can't add null to a hashSet so screen for it. if ((father != null) &amp;&amp; (father.children != null)){ allChildren.addAll(father.children); } if ((mother != null) &amp;&amp; (mother.children != null)) { allChildren.addAll(mother.children); } // If you are not in this list, there is an issue! if (allChildren.contains(this)) { allChildren.remove(this); // System.out.println("Removing self from list."); } else { System.out.println("Error: You are not a child of your parents! Adopted?"); } // Filter down to only women and get any older than me: int myAge = this.age; List oldestSisters = new ArrayList(); for (Person child : allChildren) { if (child.gender == Gender.Female) { if (child.age &gt; myAge) { oldestSisters.add(child); } } } return oldestSisters; } public List getGreatestAncestors() { if ((this.father == null) || (this.mother == null)) { return null; // You must have two parents to have ancestors } // Find root parents List myParents = getParents(this); return getElders(myParents); } private List getElders(List parents) { List elders = new ArrayList(); List myParents = new ArrayList(); boolean newElders = false; for (Person parent : parents) { myParents = getParents(parent); if (myParents.isEmpty()) { elders.add(parent); } else { elders.addAll(myParents); newElders = true; } } if (newElders == true) { return getElders(elders); } return elders; } private List getParents(Person person) { List parents = new ArrayList(); if (person.father != null) parents.add(person.father); if (person.mother != null) parents.add(person.mother); return parents; } } // For the above class, you basically have to implement 2 methods. // public List getOldestSisters() // public List getGreatestAncestors() Less

package Command; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import java.util.ArrayList; import java.util.List; import static org.junit.jupiter.api.Assertions.*; class PersonTest { // Create grand parents Person grandFatherDad = new Person(null, null, Person.Gender.Male, 78, 1); Person grandMotherDad = new Person(null, null, Person.Gender.Female, 81, 1); Person grandFatherMom = new Person(null, null, Person.Gender.Male, 69,1); Person grandMotherMom = new Person(null, null, Person.Gender.Female, 89, 1); // Create parents / aunts and uncles Person father = new Person(grandFatherDad, grandMotherDad, Person.Gender.Male, 48, 2); Person mother = new Person(grandFatherMom, grandMotherMom, Person.Gender.Female, 47, 2); Person aunt1 = new Person(grandFatherMom, grandMotherMom, Person.Gender.Female, 47, 2); // Twin sis to mom Person aunt2 = new Person(grandFatherDad, grandMotherDad, Person.Gender.Female, 37, 2); Person uncle1= new Person(grandFatherDad, grandMotherDad, Person.Gender.Male, 35, 2); // Children (me and bros and sis) Person self = new Person(father, mother, Person.Gender.Male, 18, 3); Person brother1 = new Person(father, mother, Person.Gender.Male, 16, 3); Person sister1 = new Person(father, mother, Person.Gender.Female, 15, 3); Person sister2 = new Person(father, mother, Person.Gender.Female, 14, 3); @BeforeEach void setUp() { // Create children / sibling groups List children = new ArrayList(); children.add(father); children.add(aunt1); children.add(uncle1); grandFatherDad.setChildren(children); grandMotherDad.setChildren(children); children.clear(); children.add(mother); children.add(aunt2); grandFatherMom.setChildren(children); grandMotherMom.setChildren(children); children.clear(); children.add(self); children.add(brother1); // Dad had brother with other wife children.add(sister2); father.setChildren(children); // mom came with her own daughter from prior marriage children.clear(); children.add(self); children.add(sister1); children.add(sister2); mother.setChildren(children); } @AfterEach void tearDown() { } @Test void getOldestSisters() { // When there are no older sisters and I am male: //Person me = new Person(father, mother, Person.Gender.Male, 48); List olderSisters = null; olderSisters = self.getOldestSisters(); assertTrue(olderSisters.isEmpty(), "No older sisters."); // When there is one older sister and I am male Person sister3 = new Person(father, mother, Person.Gender.Female, 50, 3); mother.addChild(sister3); father.addChild(sister3); olderSisters = self.getOldestSisters(); assertTrue(olderSisters.contains(sister3)); assertTrue(olderSisters.size() == 1, "One older full sister."); // Youngest Sister has two older sisters (one full, one half) olderSisters.clear(); olderSisters = sister2.getOldestSisters(); assertTrue(olderSisters.contains(sister1)); assertTrue(olderSisters.contains(sister3)); assertTrue(olderSisters.size() == 2, "One older full, one older half"); } @Test void getGreatestAncestors() { List ancestors = self.getGreatestAncestors(); assertTrue(ancestors.size() == 4); assert(ancestors.contains(grandFatherDad)); assert(ancestors.contains(grandFatherMom)); assert(ancestors.contains(grandMotherDad)); assert(ancestors.contains(grandMotherMom)); ancestors = father.getGreatestAncestors(); assertTrue(ancestors.size() == 2); assert(ancestors.contains(grandFatherDad)); assert(ancestors.contains(grandMotherDad)); ancestors = mother.getGreatestAncestors(); assertTrue(ancestors.size() == 2); assert(ancestors.contains(grandFatherMom)); assert(ancestors.contains(grandMotherMom)); ancestors = grandFatherDad.getGreatestAncestors(); assertNull(ancestors, "getGreatestAncestors():Persons with no ancestors should return null."); } } Less

Show More Responses
EXFO

During the first 2 rounds of 2 hours, almost everything the interviewer tried to ask which he might have collected from internet for the interviews.

5 Answers

This shows the cheap mentality of its people &amp; how such kind of people waste the valuable time of both candidates &amp; company. Less

Right, this is some kind of fraud being done by these companies to exploit the candidates &amp; take their important details for own benefits. And I think Govt should take some actions on such processes. Less

Well said &amp; agree with you that it is not a worthy company to try for where people are wasting time of the candidates. Less

Show More Responses
Wallet Hub

Write Java code to check if a string is a palindrome.

4 Answers

public class Palindrom { final Logger logger = LoggerFactory.getLogger(this.getClass().getName()); public boolean isPalindrom(String source) { int length = source.length(); String reverse = ""; for (int i = length - 1; i &gt;= 0; i--) { reverse = reverse + source.charAt(i); } return source.equals(reverse); } } Less

public static void main(String[] args) { String[] arrPalindrom = new String[]{"test","tsest","view", "viv"}; for(String item: arrPalindrom) System.out.println(item + " is " + (isItemPalindrom(item)?"palindrom": "not palindrom")); } static boolean isItemPalindrom(String str){ if(str.equals(new StringBuilder(str).reverse().toString())){ return true; } return false; } Less

static boolean isPalindrome(String str){ boolean success=true; s=s.toLowerCase(); for(int i=0;i Less

Show More Responses
Interactions

Print numbers 1 to 100 in sequence using multiple threads.

4 Answers

I don't know how did you do it, but there are various ways to do this &amp; depending on the requirements &amp; planning one can pick one. But for this small range, one can throw these many threads with right coordination. But if this range is high or CPU intensive task then better to have a pool of threads. But such questions are trivial &amp; again not sure what your interviewer was looking as the solution. Less

I just created multiple threads giving one number to each, for simple implementation &amp; just told that it is not the right &amp; should use thread pooling to avoid multiple threads &amp; he also didn't ask to try to use pool. He was complaining in the feedback that I created too many threads but he never asked me to optimize that also. Plus his ask was that all the numbers shouldn't be printed by a single thread &amp; other threads are idle, so I printed via different threads. And it gave another point to reject &amp; I am happy that I didn't give him even better solution to such people. Many interviewers use interviews to get the ideas or prepare for their own interviews with other companies, but till they get next offer letter such people try to avoid any competition in their current team. Less

I just created multiple threads giving one number to each, for simple implementation &amp; just told that it is not the right &amp; should use thread pooling to avoid multiple threads &amp; he also didn't ask to try to use pool. He was complaining in the feedback that I created too many threads but he never asked me to optimize that also. Plus his ask was that all the numbers shouldn't be printed by a single thread &amp; other threads are idle, so I printed via different threads. And it gave another point to reject &amp; I am happy that I didn't give him even better solution to such people. Many interviewers use interviews to get the ideas or prepare for their own interviews with other companies, but till they get next offer letter such people try to avoid any competition in their current team. Less

Show More Responses
Viewing 1 - 10 of 4,292 interview questions

See Interview Questions for Similar Jobs

java web developersenior java software developersenior java applications developersenior software engineersenior java developersenior java j2ee developer

Glassdoor has 4,292 interview questions and reports from Senior java engineer interviews. Prepare for your interview. Get hired. Love your job.