Computer Applications
The two Java statement are used to check for the equality of the strings "COP" and "cop" are as follows:
"COP".equals("cop")
"COP".equalsIgnoreCase("cop")
The output of the above statements is:
- false, true
- true, false
- false, false
- true, true
Java String Handling
3 Likes
Answer
false, true
Reason — In Java:
"COP".equals("cop")checks for exact match, including uppercase and lowercase letters. Since"COP"and"cop"are not exactly the same, it returns false."COP".equalsIgnoreCase("cop")checks for equality by ignoring the case of letters. So it treats"COP"and"cop"as equal and returns true.
Answered By
3 Likes
Related Questions
The output of the statement of
"TIGER".indexOf('G')is:- 3
- 2
- -1
- 0
Choose the statement which is equivalent to the given:
if(a>b) System.out.println("Honest"); else System.out.println("Sincere");a>b? System.out.println("Honest"):System.out.println("Sincere");System.out.println(a>b? "Honest":"Sincere");a>b? "Honest": "Sincere";a>b: "Honest"? "Sincere";
The output of the java statement
"SOLDIER".compareTo("SOLUTE");is- -4
- -17
- 17
- 0
Arrange the following in the descending order of number of bytes occupied.
(i) char x[20]
(ii) int a[4][2]
(iii) double b[6]- (iii), (ii), (i)
- (iii), (i), (ii)
- (ii), (iii), (i)
- (i), (ii), (iii)