Limited access

Upgrade to access all content for this subject

Consider the following code segment.

Note: Integer.parseInt() returns the integer value of the string that is passed to it.
(i.e. if "564" is passed to it, it returns 564).

String jumble = "shehas250antsinher5rooms";
String d = "0123456789";
int n1=0, n2=0;

for (int i=0; i<jumble.length(); i++)
{
    if(d.indexOf(jumble.substring(i,i+1))>=0)
        n1+=Integer.parseInt(jumble.substring(i,i+1));
    else
        n2++;
}
System.out.println(n1+n2);

What is printed as a result of executing the code segment?

A

20

B

24

C

32

D

255

E

275

Select an assignment template