Given two strings like x=?hello? and y=?open?, remove any
character from string x which is also used in string y,
thus making the result x=?hll?.

Answer Posted / guest

public static void main(String[] args) {
String str_x = "hello";
String str_y = "open";

StringBuffer result = new StringBuffer();

for (int i=0; i<str_x.length();i++){
if (str_y.indexOf(str_x.charAt(i)) < 0)
result.append(str_x.charAt(i));
}

System.out.print(result);
}

Is This Answer Correct ?    5 Yes 4 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Is abstract thinking intelligence?

775


What is meant by multiple inheritance?

926


How to handle exception in c++, For example in a functions i am assigning memory to some variables and also in next instructions in am dividing one variable also. If this functions generates a error while allocating memory to those variable and also while dividing the variable if i divide by zero then catch block how it will identify that this error has cone from perticular instruction

1866


Can static class have constructor?

778


What is abstraction with example?

817


Explain the advantages of inheritance.

852


write a code for this. serial_number contained in the header of the file will be read , if this serial number is less than a previous serial number within a successfully processed file, or is the same as another serial number within a successfully processed file, or if the field contains anything other than 7 digits, then the file must error with the reason ‘Invalid SERIAL_NUMBER’.

1972


to find out the minimum of two integer number of two different classes using friend function

1857


How do you explain polymorphism?

781


What are properties in oop?

796


How do you define social class?

795


what type of question are asked in thoughtworks pair programming round ?

1956


What is oops with example?

755


When not to use object oriented programming?

759


What is constructor in oop?

814