- ABoolean
- Bboolean
- Cbool
- Dchar
Time Taken:
Correct Answer:
Wrong Answer:
Percentage: %
boolean
Reason — isLetter() method returns true if the specified character is a letter else, it returns false. Thus, the return data type of isLetter(char) is boolean.
toUpperCase(char)
Reason — Method that converts a character to uppercase is toUpperCase(char) method.
6
Reason — indexOf() returns the index of the first occurrence of the specified character within the string and lastIndexOf() returns the index of the last occurrence of the specified character within the string. Since a string begins with index 0, the given methods are evaluated as follows:
"SUCESS".indexOf('S') + "SUCCESS".lastIndexOf('S')
⇒ 0 + 6
⇒ 6
Float
Reason — Corresponding wrapper class of float data type is Float.
Wrapper
Reason — Wrapper class is used to convert a primitive data type to its corresponding object.
GoodDay
Reason — concat() method is used to join two strings. Thus, "Good" and "Day" are joined together and printed as "GoodDay".
N - 1
Reason — The index of an array begins from 0 and continues till Size - 1. Thus, if an array has N elements, the last subscript/index will be N - 1.
private
Reason — A data member or member method declared as private is only accessible inside the class in which it is declared. Thus, it gives the least accessibility.
150.0
Reason — parseDouble() method returns a double value represented by the specified string. Thus, double values 56.0 and 94.0 are stored in C and D, respectively. Both C and D are added and 150.0 (56.0 + 94.0) is printed on the screen.
Luck
Reason — The substring() method returns a substring beginning from the startindex and extending to the character at index endIndex - 1. Since a string index begins at 0, the character at startindex (0) is 'L' and the character at the endIndex (4-1 = 3) is 'k'. Thus, "Luck" is extracted and printed on the screen.