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 I will write
String s=new String("XYZ");
String s1=new String("XYZ");
if(s.equals(s1)){
sop("True");
}
else{
sop("False");
}
This program will give me "True".
But When I am creating my own class suppose
class Employee{
public Employee(String name);
}
Employee e= new Employee("XYZ");
Employee e1 = neew Employee("XYZ");
if(e.equals(e1)){
sop("True");
}
else{
sop("False");
}
Then it will give the output as "False".
Can I know what is happening internally?

Answer Posted / ashish singh

String and other wrapper classes override equals() method of object class. SO when we compare it gives the appropriate result. while the employee class did not do it.

Is This Answer Correct ?    10 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Differentiate storage classes on the basis of their scope?

1171


What do you understand by java virtual machine?

1200


What is difference between array and vector?

1091


What's the base class of all exception classes?

1064


Is an empty arraylist null?

1100


You can create a string object as string str = “abc”; why cant a button object be created as button bt = “abc”;? Explain

994


Write java program to reverse string without using api?

1067


What is keyword in oop?

954


List any five features of java?

1033


Hi friends am new to java. I read jar file means collection of java files. For executing struts application what are the necessary jar files. " struts.jar " file contains what. can u explain

1934


What are thread local variables?

1153


Is set ordered in java?

993


What is the output of the below java program?

1048


What is meant by null and void?

977


What are the types of exceptions?

1062