In the String major = "Computer Science", what is returned by major.charAt(1)?


In the String major = "Computer Science", what is returned by major.charAt(1)?


a) 'C'

b) 'o'

c) 'm'

d) "C"

e) "Computer"

Answer: b. Explanation: Neither d nor e would be correct because charAt returns a char (single character) whereas these answers are Strings. So, the question is, which character is returned? In Java, the first character of a String is numbered 0. So charAt(1) returns the second character of the String, or 'o'.