Senior java developer Interview Questions

"Senior developers have years of experience in Java and have the knowledge and communication skills to mentor other developers. Companies prioritize strong technical skills and questions will focus on problem solving and critical thinking. A bachelor's degree in computer science or a related field, along with years of industry experience are standard."

Senior java developer Interview Questions

Senior java developer Interview Questions

"Senior developers have years of experience in Java and have the knowledge and communication skills to mentor other developers. Companies prioritize strong technical skills and questions will focus on problem solving and critical thinking. A bachelor's degree in computer science or a related field, along with years of industry experience are standard."

3,514 Senior Java Developer interview questions shared by candidates

Top Interview Questions

Sort: Relevance|Popular|Date
Senior Java Developer was asked...November 17, 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

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
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
ADP

Write a query to get the required data regarding employees.

4 Answers

You can use &amp; modify below query - select e.ename, dep.loc from emp e, (select d.deptno, d.dname, d.loc from dept d, (select deptno dno, count(*) ct from emp group by deptno order by deptno desc) dn where rownum = 1 and dn.dno = d.deptno) dep where e.deptno = dep.deptno order by e.ename; Less

I think query will be like given below. Check or change a bit for your requirements. select EMP.ENAME, lc.LOCNAME from employee emp, company org, location lc where emp.cID = ORG.CID and org.locID = lc.locID and lc.locID in ( select place.locID from ( select loc.locID, count(*) ct from employee e, company c, location loc where e.cID = c.cID and c.locID = loc.locID group by loc.locID order by ct desc) place where rownum = 1); Enjoy :) Less

These people in ADP have been in such a comfort zone that they don't like to pick more capable people who can challenge their capability disturbing their comfort zone &amp; rest who cares about the profits of the company till the time salary is getting credited in the account with less or no work. So continue to show-off &amp; keep capable people away. Less

Show More Responses
Acuitus

A rustic village contains one million married couples and no children. Each couple has exactly one child per year. Each couple wants a girl, but also wants to minimize the number of children they have, so they will continue to have children until they have their first girl. Assume that children are equally likely to be born male or female. Let p(t) be the percentage of children that are female at the end of year t. What is p(t)? "Can't tell" is a potential answer if you don't have sufficient information.

4 Answers

p(t) = 50% at all years (with some rounding) P(1) = 1,000,000 children, 500,000 of them girls, 500,000 of them boys P(2) = 500,000 more children (only those who had boys have another child), 250,000 girls, 250,000 boys so overall, there are now 750,000 girls, and 750,000 boys P(3) = 250,000 more children, 125,000 girls, 125,000 boys so there are now 875,000 girls (with 500,000 being only children, 250,000 having one brother, and 125,000 having 2 brothers), and 875,000 boys So, except for some rounding when the previous year's number of all boy families is an odd number, you will always have 50% of each Less

can't tell

The answer is 2^-t

Show More Responses
ADP

Java question was around String pattern searching which you can do easily in around 20 minutes, if you can keep your mind calm where that clock is also ticking.

4 Answers

Suggestion - Give only 10-15 minutes for the MCQs then you can easily do remaining SQL &amp; Java code questions easily in remaining time. Less

Anyone looking for the exact code then leave the message.

Answers of both these questions are over internet &amp; here on Glassdoor.

Show More Responses
Viewing 1 - 10 of 3,514 Interview Questions