Most asked top Interview Questions and Answers | Online Test | Mock Test
Education platform for interview prep, online tests, tutorials, and live practice

Build skills with focused learning paths, mock tests, and interview-ready content.

WithoutBook brings subject-wise interview questions, online practice tests, tutorials, and comparison guides into one responsive learning workspace.

Search the library
Prepare Interview

Mock Exams

Make Homepage

Bookmark this page

Subscribe Email Address

WithoutBook Forum

Ques. Please give me a sorting programming example source code on java.

- Please give me a sorting programming example source code on java.

Posted on Sep 28, 2010 by Shekhar
Ans.
import java.io.*;
class sort
{
public static void main(String ar[])throws IOException
{
DataInputStream n=new DataInputStream(System.in);
int temp,i,no,a[]=new int[20];
System.out.println("enter the no. of elements to be sorted not greater than 20");
String lim=n.readLine();
no=Integer.parseInt(lim);
System.out.println("enter the ("+no+") numbers: ");
for(i=0;i {
String q=n.readLine();
a[i]=Integer.parseInt(q);
}

for(i=0;i {
for(int j=i+1;j {
if(a[i]>a[j])
{
temp=a[i];
a[i]=a[j];
a[j]=temp;
}
}
}
System.out.println("the list after sorting is: ");
for(i=0;i System.out.println(" "+a[i]);
}
}
Posted on Sep 28, 2010 by Arindam Ghosh

Enter your Answer

Name
Email Address
Answer
Security Check
Solve this to continue: 9 + 5 = ?
©2026 WithoutBook