Explain what is the use of == and equals() method?
Submitted by: AdministratorThe == operator compare whether two object references are refer to the same instance or not.
The equals() method compare the characters(contents) of two String object.
example:
String a="Hai";
String b="Hai";
String c=new String("Hai");
System.out.println(a==b); //True
System.out.println(a==c); //False
System.out.println(a.equals(b)); //True
System.out.println(a.equals(c)); //True
Submitted by: Administrator
The equals() method compare the characters(contents) of two String object.
example:
String a="Hai";
String b="Hai";
String c=new String("Hai");
System.out.println(a==b); //True
System.out.println(a==c); //False
System.out.println(a.equals(b)); //True
System.out.println(a.equals(c)); //True
Submitted by: Administrator
Read Online Programming Concepts Job Interview Questions And Answers
Top Programming Concepts Questions
☺ | Explain how Search engines work? |
☺ | Explain what is port? what is HTTP port, FTP port, Telnet port and others? |
☺ | What is the client business process in electronic industry (in mySAP CRM)? |
☺ | Explain how to get 1,4,7,10.....rows from a table? |
☺ | Write an O(log2(N)) algorithm to find X^N? |
Top Coding/Programming Categories
☺ | Python Interview Questions. |
☺ | OOP Interview Questions. |
☺ | Software engineering Interview Questions. |
☺ | PHP Interview Questions. |
☺ | VBA (Visual Basic for Applications) Interview Questions. |