Core Java - Interview Questions and Answers for 'Sort' - 19 question(s) found - Order By Rating Q1. Difference between TreeMap and SortedMap ? Core Java
Ans. sortedMap is an interface ,while TreeMap is an implementation of sortMap.
We can not create an instance of sortedMap but we can create an instance of treeMap Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  treemap  sortedmap Q2. Explain In place sorting algorithm ? Algorithm
This question was recently asked at 'Reddit,ServiceNow'.This question is still unanswered. Can you please provide an answer. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  sorting algorithm   in place sorting algorithm Asked in 2 Companies Q3. How to sort objects based on one of the field ? Core Java
Ans. Using comparable and comparator and sorted collections like TreeSet or TreeMap.
or
use stream api from java 8 onwards which internally refers to comparable and comparator through lambda expressions Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  sort  sorting  comprator  comparable  treeset  treemap  sorting collections Asked in 1 Companies Basic   frequent Ans. https://www.geeksforgeeks.org/arrays-sort-in-java-with-examples/ Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  array  sorting Asked in 16 Companies basic   frequent Q5. What is the difference between TreeSet and TreeMap ? Core Java
Ans. TreeSet contains only values as elements whereas TreeMap contains Key value pairs. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  reeMap  TreeSet  Collections  sorted collection Asked in 1 Companies   rare Q6. Write a Program for insertion sort. Core Java
This question was recently asked at 'Ola Cabs'.This question is still unanswered. Can you please provide an answer. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  program  code  coding  insertion sort   sort Asked in 1 Companies Ans. We can merge two sorted array by using quick sort algorithm Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  arrays  merge sorted arrays Asked in 2 Companies Ans. array is traversed from first element to last element. Here current element is compared with next element. If current element is greater than next element it is swapped. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  sorting  bubble sort Asked in 1 Companies Ans. https://javasearch.buggybread.com/InterviewQuestions/questionSearch.php?searchOption=label' Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  Algorithm  Sorting Algorithm Asked in 4 Companies basic   frequent Q10. Write an algorithm / java program for Heap Sort ? Algorithm
Ans. https://www.geeksforgeeks.org/heap-sort/ Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  sorting  heap sort Asked in 1 Companies   frequent Q11. Explain various Searching and Sorting Algorithms ? Algorithm
This question was recently asked at 'HeadStrong,ServiceNow'.This question is still unanswered. Can you please provide an answer. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  Search Algorithm  Sorting Algorithm Asked in 2 Companies basic   frequent Q12. Which data structure would you recommend for ordered and sorted data? Core Java
Ans. TreeSet and TreeMap are used for maintaining sorted elements. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  ordered collections  sorted collections Asked in 1 Companies basic   frequent Q13. Write a java program to implement Quick sort ? Core Java
Ans. http://www.programcreek.com/2012/11/quicksort-array-in-java/ Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  quick sort  sort Asked in 2 Companies   frequent Q14. If I try to add Enum constants to a TreeSet, What sorting order will it use ?
Ans. Tree Set will sort the Values in the order in which Enum constants are declared. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   collections   set   treeset   enum   sorting   technical lead Q15. Which sorting algorithm is used by Collections.sort() in Java ? Core Java
Ans. The sorting algorithm is a modified mergesort. This algorithm offers guaranteed n log(n) performance. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   algorithm   collections   collections.sort   sorting algorithm expert Try 1 Question(s) Test Q16. Which of the following collection maintain its elements in Natural Sorted order ? a. HashMap b. TreeMap c. LinkedHashMap d. LinkedMap
Ans. TreeMap Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  treemap   collections   java   sorted collections   map Q17. If we add Enum constants to a sorted collection ( Treemap , TreeSet ), What will be the order in which they will be maintained ? a. Sorted Collection wont maintain them in any order. b. Insertion Order c. Order in which constants are declared. d. Natural Sorting Order.
Ans. Order in which constants are declared. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  enum   collections   sorted collections   treemap   treeset   compareto   comparable   java Q18. Collections.sort can only be performed on ..
a. Set
b. List
c. Map
d. Any Collection implementation Core Java
Ans. List Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  collections   java   sorting Try 2 Question(s) Test Q19. Write code to sort elements of a set
Ans. http://javasearch.buggybread.com/CodeSnippets/searchCodeSamples.php?&category=code&searchOption&keyword=952 Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  set  collections  sorting  treeset  code  coding