Given the following method, what method call will return true?
Public static boolean isValid(String input)
{
Boolean valid = true;
If (input.length() != 11)
{
Valid = false;
}
Else
{
If (input.charAt(3) != '-' || input.charAt(6) != '-')
{
Valid = false;
}
Else
{
Valid =
Character.isDigit(input.charAt(0) ) &&
Character.isDigit(input.charAt(1) ) &&
Character.isDigit(input.charAt(2) ) &&
Character.isDigit(input.charAt(4) ) &&
Character.isDigit(input.charAt(5) ) &&
Character.isDigit(input.charAt(7) ) &&
Character.isDigit(input.charAt(8) ) &&
Character.isDigit(input.charAt(9) ) &&
Character.isDigit(input.charAt(10) ) ;
}
}
Return valid;
}
A) isValid("123-45-67")
B) isValid("123-456789")
C) isValid("123-45-6789")
D) isValid("ABC-45-6789")
Correct Answer:
Verified
Q72: Given the following method that checks for
Q73: An effective technique for understanding the subtle
Q74: A temporary method that is used to
Q75: Given the following method, what do we
Q76: In the following code snippet, what is
Q78: Which of the following options represents the
Q79: For a program that reads three letter
Q80: What is incorrect in the following code
Q81: What is the output of the following
Q82: Which of the following code snippets returns
Unlock this Answer For Free Now!
View this answer and more for free by performing one of the following actions
Scan the QR code to install the App and get 2 free unlocks
Unlock quizzes for free by uploading documents