Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


if we give input as " hi how are you" then the output
should be "uoy woh"...it should skip odd words in the input
and should reverse even words from the end of string...can
anyone help me to write this program in java



if we give input as " hi how are you" then the output should be "uoy woh"...it..

Answer / nagesh

package test;



public class TestClass {

/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
StringBuffer sb = new StringBuffer("hi how
are you");
String input = sb.reverse().toString();



String output = "";
String[] stInput =input.split(" ");


for(int i=0;i<stInput.length;i++)
{
if(i%2==0)
{
if(i==0)
{
output = stInput[i];
}
else
{
output = output + " "+
stInput[i];
}

}

}


System.out.println("Output String is =="+output);
}

}

Is This Answer Correct ?    6 Yes 0 No

Post New Answer

More Core Java Interview Questions

we r taking <load-on-startup>0</load-on-startup> <load-on-startup>1</load-on-startup> in deployment descripter for loading servlets like serv1 N serv2? so 'll it take serv1 or serv2

2 Answers   CSC,


What is a constructor, constructor overloading in java?

0 Answers  


What are the advantages of java?

0 Answers  


How do you remove duplicates from an array in java?

0 Answers  


What does snprintf return?

0 Answers  


What are the major advantages of internal iteration over external iteration?

0 Answers  


Tell me about different OOPS concepts.

0 Answers   Amdocs,


Explain about global variables in Java?

3 Answers  


Tell some latest versions in JAVA related areas?

0 Answers  


what is singlton class?where it is use in real time senario.

1 Answers   Wipro,


What are inner classes or non static nested classes in java?

0 Answers  


What is the different between get and post?

0 Answers  


Categories