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

How do you remove all elements from an arraylist in java?

1020


What does main method?

974


What is mnemonic in assembly language?

1068


Describe the Big-O Notation.

1040


What is the purpose of the finalize() method?

1244


Is void a return type?

961


What is the difference between delete and delete[]

1529


What is the static field modifier?

1122


What modifiers may be used with an inner class that is a member of an outer class in java programming?

1096


What is the difference between Grid and Gridbaglayout?

1235


Why is java so important?

1109


What is java objectoutputstream?

979


Which package has light weight components?

983


What is a singleton factory?

954


What is the largest long allowed by java?

1057