ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage   interview questions urls   External Links  Contact Us     Login  |  Sign Up                      
info       Did you received any Funny E-Mails from your Friends and like to share with rest of our friends? Yeah!! you can post that stuff   HERE
Google
 
Categories  >>  Software  >>  Programming Languages  >>  C++  >>  OOPS
 
 


 

 
 STL interview questions  STL Interview Questions
 OOPS interview questions  OOPS Interview Questions
 C++ General interview questions  C++ General Interview Questions
Question
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?. 
 Question Submitted By :: Kunal
I also faced this Question!!     Rank Answer Posted By  
 
  Re: 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
# 1
int countX=0;
int countY=0;
string tmp=x;
for(countX=1;countX<=x.lenth();countX++)
{
  for(countY=1;countY<=y.length();countY++)
  {
    if x.substring(1,countX).Equels(y.substring(1,countY)
    {
      tmp=tmp.Replace(tmp.substring(1,countX),"");
    }
  }
}
x=tmp;
 
Is This Answer Correct ?    0 Yes 0 No
Sourabh Bose
 
  Re: 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
# 2
'e'and 'o'
 
Is This Answer Correct ?    1 Yes 1 No
Gopichandar
 
 
 
  Re: 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
# 3
x="hello", y="open"
so we have to remove e and o from x, so its hll
 
Is This Answer Correct ?    0 Yes 1 No
Shilpa
 
  Re: 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
# 4
class Stringb
{

	public static void main(String a[])
	{
	StringBuffer sb=new StringBuffer("Hello");
	StringBuffer sb1=sb.deleteCharAt(1);
	StringBuffer sb2=sb1.deleteCharAt(3);
	System.out.println(sb2);
	}
}
 
Is This Answer Correct ?    0 Yes 1 No
Nisha Sharma
 
  Re: 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
# 5
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 ?    0 Yes 0 No
Guest
 
  Re: 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
# 6
Public  abstract ClassDemo
{
public static void main(string args[]){
StringBuffer sb1= new stringBuffer("Hello");
StringBuffer sb2= new stringBuffer("open");
stringbuffer a= sb.deletecharacterAt("hello",1);
system.out.println("the value of a:"+a);
stringBuffer x=sb.deletecharacterAt("hllo"3);
system.out.println(x:+"x");
}
 
Is This Answer Correct ?    0 Yes 0 No
Bijoy Kumar Baral
 
  Re: 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
# 7
static public string StupidQuestion(string x, string y)
{
    StringBuilder sb = new StringBuilder();
    Hashtable ht = new Hashtable();

    // just one pass through y
    foreach( char c in y.ToCharArray() )
        if( !ht.Contains(c) )
               ht.Add(c, c)

    // just one pass thru x
    foreach( char c in x.ToCharArray() )
        if( !ht.Contains(c) )
          sb.Append(c);

    return sb.ToString();
}
 
Is This Answer Correct ?    0 Yes 0 No
Skybeaver
 
  Re: 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
# 8
using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            string str = "mohim";
            string str1 = "mo";
            remove(str, str1);
        }
        private static void remove(string str,string str1)
        {
            char[] abc;
            abc = str.ToCharArray();
            char[] bcd;
            string str4 = "";
            bcd = str1.ToCharArray();
            for (int i = 0; i < bcd.Length; i++)
            {
                for (int j = 0; j < abc.Length; j++)
                {
                    if (abc[j] != bcd[i])
                    {
                        
                       str4 = str4 + abc[j];
                    }
                }
                abc = str4.ToCharArray();
                str4 = "";
            }
            Console.Write(abc);
            Console.ReadLine();

        }
    }
}
 
Is This Answer Correct ?    0 Yes 0 No
Jethvamohit
 

 
 
 
Other OOPS Interview Questions
 
  Question Asked @ Answers
 
When is it necessary to use member-wise initialization list in C++?  1
is java purely oop Language? Infosys22
What is R T T I ? Ness-Technologies3
Why do we use virtual functions?  3
WILL I GET A guaranteed JOB AFTER DOING bsc()IT) and GNIIT from an NIIT CENTRE?? Biocon1
What are virtual functions?  2
Definition of Object Oriented Programming in single line? TCS14
What is an orthogonal base class?  1
Can we have a private constructor ? Ness-Technologies8
What are the advantages of inheritance?  2
write a program in c++ to overload the function add (s1,s2) where s1 and s2 are integers and floating point values.  1
What is command routing in MFC GE1
features of OOPS Ness-Technologies5
In which Scenario you will go for Interface or Abstract Class?  1
Why many objects can working together? How objects working togetherM I want to see example code.  2
What is polymorphism? Explain with an example.  7
What do you mean by public, private, protected and friendly?  1
how to swap to variables without using thrid variable in java?  3
what is the usage of clas templates  5
Difference between realloc() and free? HP3
 
For more OOPS Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com