Give the output of the following string functions:
- "ACHIEVEMENT".replace('E', 'A')
- "DEDICATE".compareTo("DEVOTE")
Single Choice
Views 71
Answer:
- ACHIAVAMANT
- -18
- "ACHIEVEMENT".replace('E', 'A') will replace all the E's in ACHIEVEMENT with A's.
- The first letters that are different in DEDICATE and DEVOTE are D and V respectively. So the output will be:
ASCII code of D - ASCII code of V
⇒ 68 - 86
⇒ -18
Related Articles:
This section is dedicated exclusively to Questions & Answers. For an in-depth exploration of Java Programming Language, click the links and dive deeper into this subject.
Join Our telegram group to ask Questions
Click below button to join our groups.