Java - Interview Questions and Answers for 'Sorting' | Search Java Interview Question - javasearch.buggybread.com
Javasearch.buggybread.com
Share

Search Java Interview Questions


 2098 questions in repository.
 There are more than 200 unanswered questions.
Click here and help us by providing the answer.
Label / Company      Label / Company / Text

   



Interview Questions and Answers for 'Sorting' - 9 question(s) found - Order By Newest

 Q1. Collections.sort can only be performed on ..

a. Set
b. List
c. Map
d. Any Collection implementation
Core Java
Anonymous
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


 Q2. If I try to add Enum constants to a TreeSet, What sorting order will it use ?
Admin
info@buggybread.com
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


 Q3. Which sorting algorithm is used by Collections.sort() in Java ?Core Java
Admin
info@buggybread.com
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


 Q4. 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


 Q5. Write an algorithm / java program for Heap Sort ?Algorithm2017-01-19 15:36:18

 This question was recently asked at 'Deloitte'.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  heap sort     Deloitte        frequent


 Q6. Write any sorting algorithm.Algorithm2017-01-25 13:41:50

 This question was recently asked at 'Colgate Palmolive,LDS Church,TPG Axon Capital Management'.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     Algorithm  Sorting Algorithm     Colgate Palmolive  LDS Church  TPG Axon Capital Management      basic        frequent


 Q7. Explain bubble sort.Algorithm2017-03-03 14:28:51

 This question was recently asked at 'Amazon'.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  bubble sort     Amazon


 Q8. Write a Program for selection sort.2017-07-27 11:59:53

Ans. public class SelectionSort {
   public static void main(String[] args){
      int a[] = {1,3,4,5,7,8,2,6};
      
      for(int i=0;i<a.length;i++){
         for(int j=0;j<i;j++){
            if(a[j] > a[j]){
               int temporary = a[j];
               a[j] = a[i];
               a[i] = temporary;
            }
         }
      }
      
      for(int i=0;i<a.length;i++){
         System.out.println(a[i]);
      }
   }
}

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     sorting algorithm  selection sort


 Q9. Write a program for bubble sort.2017-07-27 12:00:59

Ans. public class BubbleSort {
   public static void main(String[] args){
      int a[] = {1,3,4,5,7,8,2,6};
      
      for(int i=0;i<a.length-1;i++){
         for(int j=i;j<a.length;j++){
            if(a[j] < a[j]){
               int temporary = a[j];
               a[j] = a[i];
               a[i] = temporary;
            }
         }
      }
      
      for(int i=0;i<a.length;i++){
         System.out.println(a[i]);
      }
   }
}

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     sorting algorithm  Bubble sort




Subscribe to Java News and Posts. Get latest updates and posts on Java from Buggybread.com
Enter your email address:
Delivered by FeedBurner



comments powered by Disqus
 

Help us and Others Improve. Please let us know the questions asked in any of your previous interview.

Any input from you will be highly appreciated and It will unlock the application for 10 more requests.

Company Name:
Questions Asked:
         

X Close this

X Close this

Help Us Improve.
Please share your
interview experience.

Company Name:   


Questions Asked: