What is the value of the following statements?String a = "abc"; String s = a; String t;
'b' + 2 == 'd'(char)('5' - 0)t.length()s == a5 + aa.toUpperCase()(a.length() + a).startsWith("a")"Algorithm".indexOf("r")"Algorithm".substring(0,4)"Algorithm".substring(2).startsWith("go")a.substring(1) == "bc""ab".compareTo("ac")
String n = new String("Make OOP Fun");
foobar(n);
System.out.println(n);
What will this code print? Does it depend on actual implementation of the foobar()
method? Explain your answer.
"Make OOP Fun". It does not depend on the actual implementation of the foobar() method. Strings cannot be changed.
public void printASCII(){
for(char letter='A'; letter <= 'Z'; letter++){
System.out.println(letter + " " + (int)(letter));
}
}
public int countVowels(String s){
int count = 0;
String vowels = "aeiou";
String lower = s.toLowerCase();
for(int i=0; i<s.length(); i++){
if(vowels.indexOf(lower.charAt(i))> -1)
count++;
}
return count;
}