Leave a Reply 4

Your email address will not be published. Required fields are marked *


Ryan

Ryan

I don’t feel like typing this one out again but the result I got was B.
Out of limits
hEllOjAvA!

obrain

obrain

I think:
A. Out of limits (only)
message is out of try-catch

hugo

hugo

But what is the code for the question?

Rajesh

Rajesh

public class TestTry {
public static void main(String[] args) {
StringBuilder message = new StringBuilder(“hello java!”);
int pos = 0;
try {
for(pos = 0 ; pos < 12; pos++) {
switch (message.charAt(pos)) {
case 'a':
case 'e':
case 'o':
String uc = Character.toString(message.charAt(pos)).toUpperCase();
message.replace(pos, pos + 1, uc);
}
}
} catch (Exception e ) {
System.out.println("Out of limits");
}
System.out.println(message);
}
}

Correct Answer:
Option B:
Out of limits
hEllO jAvA!