write a program, when a statement is entered, it should
display in reverse order.
Ex: Statement is "I am writing program in reverse order".
Output should be like "order reverse in program writing am I".

Answers were Sorted based on User's Feedback



write a program, when a statement is entered, it should display in reverse order. Ex: Statement i..

Answer / vishal

public class Reverse {
public static void main(String[] args) {
String sentence="I am writing program in reverse order";
String[] temp=sentence.split(" ");
for(int i=temp.length-1;i>=0;i--){
System.out.print(temp[i]+" ");
}
}
}

Is This Answer Correct ?    16 Yes 3 No

write a program, when a statement is entered, it should display in reverse order. Ex: Statement i..

Answer / abhinaw kumar

package com.test;

public class ReverseString {

public static String reverse(String sentence){
String[] temp=sentence.split(" ");
StringBuffer sb = new StringBuffer();
for(int i=temp.length-1;i>=0;i--){
sb.append(temp[i]+" ");
}
sentence = sb.toString();
return sentence;
}

public static void main(String[] args) {
String sentence="I am writing program in reverse order";
String revString = reverse(sentence);
System.out.println(revString);

}
}

Is This Answer Correct ?    4 Yes 1 No

write a program, when a statement is entered, it should display in reverse order. Ex: Statement i..

Answer / ram shringar

public class Test {
public static void main(String abb[])throws Exception
{ int i=3;
String string[]=abb;
for(i=string.length-1;i>=0;i--)
{
System.out.print(string[i]+" ");
}
}
}

Is This Answer Correct ?    0 Yes 1 No

write a program, when a statement is entered, it should display in reverse order. Ex: Statement i..

Answer / shobhit awasthi

//its code based on command line argument means u give the in run time like java "hello how r u " its convert" u r how hello" if u increase statement lenth u increase i//
class demonew
{
public static void main(String abb[])throws Exception
{ int i=3;
String string;
for(i=3;i>=0;i--)
{
string=abb[i];
System.out.println(string);
}
}
}

Is This Answer Correct ?    0 Yes 3 No

Post New Answer

More J2EE Interview Questions

What is enterprise information system resource?

0 Answers  


What is authorization?

0 Answers  


Is object a composite data type in java?

0 Answers  


Why is j2ee needed?

0 Answers  


What is source file in java?

0 Answers  






What is a web container in j2ee?

0 Answers  


What is the concept of connection pooling?

0 Answers  


Whats the O/p of the below code snippet ? And explain how does it imply the concept of call-by-value/call-by reference. (PS : Pls ignore syntax errors) public class One { public oneA(){ sop ("Into One--");} } public class Two extends One{ public twoT(){ sop ("Into Two--"); } } public class Home { One a; Two t; public static void main(argv[]) { sop ("In Home--"); sop(a.oneA()); sop(t.oneA()); sop(a.twoT()); sop(t.twoT()); } }

4 Answers   Wipro,


What is layout manager in java?

0 Answers  


What is j2ee application?

0 Answers  


What is javaserver pages (jsp)?

0 Answers  


What is external entity?

0 Answers  


Categories