Java developer Interview Questions | Glassdoor.ca

Java developer Interview Questions

407

java developer interview questions shared by candidates

Top Interview Questions

Sort: RelevancePopular Date

Given an array of pairs of numbers, simplify the numbers. The pairs represent ranges, and the result is a simplified version of these pairs. So [1,5],[3,7] should result in [1,7].

3 Answers

Sort the pairs by the left number, and loop through combining if they overlap. Make sure to check the results, as multiple pairs can combine together to form a big range.

var x = [[6,5],[3,7],[6,2],[3,20]]//array of pair of numbers; //Function returns smaller of two values var smaller = function(n){ if (n[0] n[1]) { return n[0] } else {return n[1]} } //functions to sort array in ascending order var sort = function (a,b){ return a - b; } function simplifyRange(x,smaller,bigger){ var finalarray = []; var minarray = x.map(function(n){ return smaller(n); }); var maxarray = x.map(function(n){ return bigger(n); }); minarray = minarray.sort(sort); maxarray = maxarray.sort(sort); finalarray.push(minarray[0],maxarray[maxarray.length-1]) return finalarray } console.log(simplifyRange(x,smaller,bigger));

var x = [[6,5],[3,7],[6,2],[3,20]]//array of pair of numbers; //Function returns smaller of two values var smaller = function(n){ if (n[0] n[1]) { return n[0] } else {return n[1]} } //functions to sort array in ascending order var sort = function (a,b){ return a - b; } function simplifyRange(x,smaller,bigger){ var finalarray = []; var minarray = x.map(function(n){ return smaller(n); }); var maxarray = x.map(function(n){ return bigger(n); }); minarray = minarray.sort(sort); maxarray = maxarray.sort(sort); finalarray.push(minarray[0],maxarray[maxarray.length-1]) return finalarray } console.log(simplifyRange(x,smaller,bigger));

What is a singleton?

2 Answers

What are you top 3 weaknesses and your top strength?

2 Answers

Are you willing to travel?

2 Answers

Typical Java technical questions. Like how to generate a deck of cards and then shuffle them.

2 Answers

Programming question about Stack.

2 Answers

-Tell me about a project that you are proud of. What challenges did you face while you were dealing with the project?

1 Answer

The interview question was about implementing a game: 4-connected disks game!

1 Answer

Is Java pass-by-reference or pass-by-value?

1 Answer

Heap meaning, some patterns, class path definition, if I face a situation with a complicated colleague, very basic questions, not challenging at all.

1 Answer
110 of 407 Interview Questions