Given the following code, what is the output?
Public static String magic(String s)
{
String r = "";
Boolean got = false;
For (int i = 0; i < s.length() ; i++)
{
If (Character.isDigit(s.charAt(i) ) )
{
R = r + s.charAt(i) ;
Got = true;
}
Else if (got)
{
Return r;
}
}
Return r;
}
Public static void main(String[] args)
{
System.out.println(magic("ABCd45&*31") ) ;
}
A) ABCd
B) 4531
C) 45&*
D) 45
Correct Answer:
Verified
Q37: What are the values of x and
Q38: What are the values of num1 and
Q39: What is the output of the following
Q40: What can be used as an argument
Q41: What step should you take after implementing
Q43: What is incorrect in the following code
Q44: Given the following code, which argument(s) will
Q45: What is wrong with the following code?
Public
Q46: Which of the following is the best
Q47: What is wrong with the following code?
Public
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