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  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  >>  Core Java  >>  Java J2EE  >>  Java Related
 
 


 

 
 Core Java interview questions  Core Java Interview Questions
 Advanced Java interview questions  Advanced Java Interview Questions
 Swing interview questions  Swing Interview Questions
 EJB interview questions  EJB Interview Questions
 Servlets interview questions  Servlets Interview Questions
 Struts interview questions  Struts Interview Questions
 JDBC interview questions  JDBC Interview Questions
 JMS interview questions  JMS Interview Questions
 SunOne interview questions  SunOne Interview Questions
 J2EE interview questions  J2EE Interview Questions
 Weblogic interview questions  Weblogic Interview Questions
 Websphere interview questions  Websphere Interview Questions
 Java Networking interview questions  Java Networking Interview Questions
 Java J2EE AllOther interview questions  Java J2EE AllOther Interview Questions
Question
What method is used to compare two strings ?
 Question Submitted By :: Guest
I also faced this Question!!     Rank Answer Posted By  
 
  Re: What method is used to compare two strings ?
Answer
# 1
The == operator works on String object references. If two
String variables point to the same object in memory, the
comparison returns a true result. 

The equals method compares the actual char content of two
strings. This method returns true when two String objects
hold char data with the same values.
 
Is This Answer Correct ?    1 Yes 1 No
Suman
 
  Re: What method is used to compare two strings ?
Answer
# 2
If string a="aaaa"; and String b="bbbb";
we can compare them as
if(a.equals(b)) and get a boolean as a return type.

////////////////////////////////////////////////////////

We can also compare String as 
a.compareTo("aaaa"); which gives 0 as output as they are 
equal.
 
Is This Answer Correct ?    2 Yes 2 No
Interviewall
 
 
 
  Re: What method is used to compare two strings ?
Answer
# 3
by overriding the compare method of comparator class
 
Is This Answer Correct ?    0 Yes 1 No
Ravikiran(aptech Mumbai)
 
  Re: What method is used to compare two strings ?
Answer
# 4
we can use a string function...
eg:
strcmp("string1","string2")
it return 0 if string1=string2
it return >0 if string1>string2
it return <0 if string1<string2.
value returned depends on anscii calues of strings...
 
Is This Answer Correct ?    1 Yes 0 No
K.b.s.reddy
 

 
 
 
Other Core Java Interview Questions
 
  Question Asked @ Answers
 
why String class is immutable. iGate3
how many design pattern r there? and wht design pattern u use and why ? HP5
primitive data types in Java ?  3
class A{ m2(){ } } class B extends A{ m2(){ } } class c extends B{ m2(){ } } class my_class extends c{ m2(){ } pulic static void main(){ ...My_class a = new my_class(); super.super.super.m2(); is this is leagal if not find what is the legal procedure in order to call A's version of m2(); } Logica-CMG8
what is an virtual function TCS2
What is compile time polymorphism? Elementus-Technologies6
What is the diff. b/w Interfaces & Abstract class? Ericsson4
static inner classes means..?  1
What is casting? BMC3
Which method is used to find that the object is exited or not?  1
what are depricated methods ? Satyam4
how u do unit testing? iFlex2
what release of java technology are currently available what do they contain?  1
Difference between this(), super()?  8
Explain Connection Pooling?  3
What happens if an exception is not caught?  4
what is the difference between the "protected and default" modifiers?  4
what is the difference between static block and static method Huawei9
How are Java source code files named?  3
why the primitive data type have classes?  2
 
For more Core Java Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

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