Senior software engineer java Interview Questions | Glassdoor.co.uk

# Senior software engineer java Interview Questions

1,463

senior software engineer java interview questions shared by candidates

## Top Interview Questions

Sort: RelevancePopular Date

9 Sep 2015
 Except experience related questions I was asked coding question and I was supposed to write the solution to the problem in any programming language in a simple web-based code editor. The question was: given and array of positive integers and another integer find whether there is a consecutive range in the array, so that the sum of integers in the range is equal to the given number. They put an emphasis on delivering working, efficient solution. In my opinion this kind of interview requires a thorough preparation. 5 AnswersEfficient solution you say? Its easy to do it in O(N^2) but I think you mean the O(N*logN) solution. It took me about 5-10 minutes to come up with m, but I am not sure I would be able to write the full source code for this solution in a short period of time. If you did it - then thumbs up man!Two answers, 2nd is O(n) {code} boolean findSum (int[] a, int index, int n) { if (n == 0) return true; if (index > a.size) return false; for (int i = index; i n) sum -= a[sp++]; } return false; } {code}Corrected a bug in solutions 2 abShow more responsesCorrected a bug in solution 2 above: boolean findSum (int[] a, int n) { int sum = 0, sp = 0; for (int i = 0; i n) { sum -= a[sp]; if (sp < i) { sp++; i--; // this is because i increments for each loop continue; } } sum += a[i]; if (sum == n) return true; } return false; }public static void findSum(List A, int k){ int runningSum = 0, fast = 0, slow = 0; while(fast k && slow <= fast) { runningSum -= A.get(slow++); } if(runningSum == k){ System.out.println(slow + " : " + (fast-1)); break; } } }

30 Jun 2014

4 Jun 2015
 Find Kth minimum node in a binary tree and suggest a complexity5 Answers-- Convert the binary tree into a MinHeap binary tree from the nodes -- delete K nodes from the MinHeap binary tree. Complexity : Time required to construct the Min heap by an optimized way: n Time required to delete K nodes from the binary tree = O(K log n) Total complexity : O(n + K log n) Another solution: -- parse the whole tree and find and store the node with the minumum value and delete that node. -- repeat the exercise for K times and the value found in K th parse is the intended value Total complexity : O(Kn)Supposing a BST, where the Node struct is expanded with "int size" which defines the size of its subtree included itself: public Node fintMinimum(Node root, int k) { if (root == null) return null; if (k = k) { return findMinimum(root.left, k); } return findMinimum(root.right, k-(root.left.size+1)); } }Show more responsesConvert the bin tree into a BST [O(n)]. Traverse k elements of the BST [O(k log n)]. Total O(n+k log n).Do a preorder traversal of the tree which is O(n). Then use a pivot quicksort method to find the kth index which is K(log(n)). So the total runtime is O(n +K(log(n))) One or more comments have been removed. Please see our Community Guidelines or Terms of Service for more information.

### Senior Software Engineer at ClearBank was asked...

18 Sep 2018
 Received solution for refactoring.3 Answersrefactored using SOLID principles.I don't think they are really recruiting anyone people. In my case, they just told me that my code did not pass by their internal assessment system. But, they did not say what wrong in my code and why it is failed.Sat the refactoring test and had no feedback. Chased the Job Recruiter who is never at his desk. How strange. Clear Bank are a waste of time, I would keep clear.

4 Aug 2017
 Write algorithm to convert number for example 16 138 832 into "sixteen million one hundred thirty eight thousand eight hundred thirty two"3 AnswersIt was hard to write under pressure. Basically, I was using HashMap. Key for integer, value for spelling. Solution you can find somewhere at leetcodehaven't checked leetcode, but how about this? firstly use (int)(Math.log10(number) + 1) to get the number of digits in the given number. (Note: you have to handle 0 differently) e.g 16138832 should return 8. Use this number of digits to get an idea of digit place's spelling (billion, million, thousand, hundred) Then for each digit (0~9) I'm thinking of using the previous answer's suggestion of HashMap to get the spelling. So I imagine there would be two HashMaps, one for getting the digit spelling (one, two, ... nine, ten, ... , nineteen), the other for the digit place spelling (billion, million, thousand, hundred, ... thirty, twenty)Here is the answer. Sorry for the extra spaces :) private static String spellNumber(String number) { HashMap level1Num = new HashMap(); level1Num.put(1, " one "); level1Num.put(2, " two "); level1Num.put(3, " three "); level1Num.put(4, " four "); level1Num.put(5, " five "); level1Num.put(6, " six "); level1Num.put(7, " seven "); level1Num.put(8, " eight "); level1Num.put(9, " nine "); level1Num.put(10, " ten "); level1Num.put(11, " eleven "); level1Num.put(12, " twelve "); level1Num.put(13, " thirteen "); level1Num.put(14, " fourteen "); level1Num.put(15, " fifteen "); level1Num.put(16, " sixteen "); level1Num.put(17, " seventeen "); level1Num.put(18, " eighteen "); level1Num.put(19, " ninteen "); HashMap level2Num = new HashMap(); level2Num.put(2, " twenty "); level2Num.put(3, " thirty "); level2Num.put(4, " fourty "); level2Num.put(5, " fifty "); level2Num.put(6, " sixty "); level2Num.put(7, " seventy "); level2Num.put(8, " eighty "); level2Num.put(9, " ninty "); String output = ""; while (number.length() > 0) { String block; if (number.length() % 3 == 0) { block = number.substring(0, 3); } else { block = number.substring(0, (number.length() % 3)); } if (block.length() > 2) { output += level1Num.get(Integer.parseInt(block.substring(0, 1))) + " hundred "; number = number.replace(block.subSequence(0, 1), ""); block = block.replace(block.subSequence(0, 1), ""); } int block2 = Integer.parseInt(block); if (block2 = 7 && number.length() = 4 && number.length() <= 6) { output += " thousand"; } number = number.replace(block, ""); } return output; }

### Senior UI Developer at Barclays was asked...

29 Oct 2015
 Write a javascript function to draw a chessboard3 AnswersUsing a loop and mod function, obvs.div.chess-row { height:35px; } div.chess-column { height: 35px; width: 35px; display: inline-block; border:solid 1px black; } div.chess-column.black-cell { background-color:black; } for(var i=1;idiv.chess-row { height:35px; } div.chess-column { height: 35px; width: 35px; display: inline-block; border:solid 1px black; } div.chess-column.black-cell { background-color:black; } Js:- for(var i=1;i<=8;i++) { var chessRow=document.createElement("div"); chessRow.classList.add("chess-row"); chessRow.classList.add("chess-row_"+i); document.querySelector('body').appendChild(chessRow); for(j=1;j<=8;j++) { var chessColumn=document.createElement("div"); chessColumn.classList.add("chess-column"); if(((i+j)%2)==0) { chessColumn.classList.add("black-cell") } document.querySelector('body .chess-row_'+i).appendChild(chessColumn); } }

### Senior Software Engineer at SAP Concur was asked...

14 Sep 2012
 How will you prevent the code in finally block from executing? The question isn't a very fair one as a good programmer would not write the code in finally block that he/she doesn't want to execute3 Answersif(false)Its just to check logic, finally will not run if system.exit(0) is called.Kind of a trick question. Finally block is always code if the try block is executing, only way to guaranty finally is not called is to not enter the try block.... or pull the plug on the JVM

### Senior Software Engineer at Inspired Gaming was asked...

28 Jul 2015
 All questions around multithreading.2 AnswersI was able to answer most of them.How much time it takes to complete the interview procedure? How can we know whether we cleared the first level or not

### Senior Software Developer at OVO was asked...

2 May 2017
 Given these meter readings, write a program that outputs usage by month2 AnswersMy answer was insufficient because I did not write enough tests (though I wrote some, so bear that in mind)Could you give us a bit more information about the problem? Did you have to write a full solution from scratch, or just implement the method that finds the usage per month? Also, were the readings given as a list or as a stream which would constantly give you readings?

### Senior Software Engineer at ITV was asked...

10 Jun 2019
 When was the last time you made a mistake?2 AnswersI make mistakes a lot better I'm always trying new things. It aides innovationWhat is covered in coding test? Was it hard?
110 of 1,463 Interview Questions