Write a program to display numeric value in reverse order.
Ex: I have given a number like 7584, It should display in
reverse order like 4857.

Answers were Sorted based on User's Feedback



Write a program to display numeric value in reverse order. Ex: I have given a number like 7584, It ..

Answer / pankaj

int n=1856,rem,n1,temp=0;

for(int i=0;n>=1;i++)
{
rem=n%10;
n=n/10;
temp=(temp*10)+rem;
}

Is This Answer Correct ?    7 Yes 0 No

Write a program to display numeric value in reverse order. Ex: I have given a number like 7584, It ..

Answer / srikanth

import java.io.*;
class palin{
public static void main(String as[]){
try{
InputStreamReader isr=null;
BufferedReader br=null;
br=new BufferedReader(new InputStreamReader(System.in));
int num=Integer.parseInt(br.readLine());
System.out.println(num);
int n=num;
int rev=0;
System.out.println("number");
System.out.println(num);
for(int i=0;i<=num;i++){
int r=num%10;
num=num/10;
rev=rev*10+r;
i=0;
}
System.out.println("after reversing"+rev);
if(n==rev){
System.out.println("number is palic");
}
else{

System.out.println("number is not palic");
}
}catch(Exception e){
System.out.println(e);
}
}
}

Is This Answer Correct ?    6 Yes 0 No

Write a program to display numeric value in reverse order. Ex: I have given a number like 7584, It ..

Answer / selvi

import java.util.Scanner;

public class IntReverseOrder
{
public static void main(String args[])
{
Scanner scan = new Scanner(System.in);
int num = scan.nextInt();
StringBuffer sb = new StringBuffer();
int remainder;

while(num>0)
{
remainder = num%10;
sb = sb.append(remainder);
num = num/10;

}
System.out.println("Reverse Order = "+sb);
}

}

Is This Answer Correct ?    4 Yes 1 No

Write a program to display numeric value in reverse order. Ex: I have given a number like 7584, It ..

Answer / pradyumna

public class Test1 {
public static void main(String[] args) {
StringBuffer s1 = new StringBuffer("1234");
System.out.println(s1);
s1.reverse();
System.out.println(s1);

}
}

Is This Answer Correct ?    3 Yes 0 No

Write a program to display numeric value in reverse order. Ex: I have given a number like 7584, It ..

Answer / ravi

Hi Deepak,

Thanks for responding....

You simple hard coded the script. If user given dynamic
values. what will be the result?

Is This Answer Correct ?    2 Yes 2 No

Write a program to display numeric value in reverse order. Ex: I have given a number like 7584, It ..

Answer / deepak

public class A
{
public static void main(String str[])
{
String s="7584";
System.out.println(s);
s.reverse();
System.out.println(s);
}}

Is This Answer Correct ?    7 Yes 9 No

Post New Answer

More J2EE Interview Questions

what is Directory Structure of webapplication?

8 Answers   CTS, Virtusa,


What is the best java compiler?

0 Answers  


Is advanced java and j2ee same?

0 Answers  


what is data modeling?what is final method

1 Answers   Oracle,


How many types of objects are there in java?

0 Answers  


What are the differences between Ear, Jar and War files? Under what circumstances should we use each one?

0 Answers  


What is a panel java?

0 Answers  


What is tomcat in j2ee?

0 Answers  


i developed a Stateless Session bean program.And created a client by a common java class as class m {p s v m(String s[]){....}} And i called the bean deployed in weblogic.from cmd prompt And that run. mind it i have to set setenv,seting classpath for that bean jar file before compile and run it. ok when i do a servlet programme deployed in tomcat and call that bean then it give classdefnotfoundException and NoInitialContext like this.So how i sucessfully do this? Ok when i call that bean from java class from the console like i previously told, if i don't set setenv i found the same error on the cmd prompt. pls help to get out of it

2 Answers  


I’m new to WebLogic Does anyone knows how to Deploy Application using

0 Answers  


Why java is called robust and secure?

0 Answers  


Why frameworks are used in java?

0 Answers  


Categories