PRASHNIKAप्रश्निका
‹ Back to the paper

String Description StringA Password entered by the user StringB Password stored by the system…

Computer Science20251 markMCQ
StringDescription
StringAPassword entered by the user
StringBPassword stored by the system
Passwords are stored as two Strings-one is the user entered password saved in StringA, the other is a password stored by the system in StringB. If StringA must be checked with StringB, for validity, which one of the following String functions are needed to be used?
  • acharAt( )
  • bequals( )
  • cequalsIgnoreCase( )
  • dstartsWith( )

Answer

Answer

AI

Correct option: b

Answer: (b) equals( ). A password check needs an exact, case-sensitive comparison, which String's equals( ) method gives. equalsIgnoreCase( ) would wrongly accept passwords differing only in case, and charAt( )/startsWith( ) do not compare the whole string.
Arrays, Strings

From ISC Computer Science - Competency Focused Practice Questions (CISCE, August 2024), question 7.