Java | Functions | Question 11
Predict the output of the following program.
class Test { public static void main(String[] args) { String str = "geeks"; str.toUpperCase(); str += "forgeeks"; String string = str.substring(2,13); string = string + str.charAt(4);; System.out.println(string); } } |
chevron_right
filter_none
(A) eksforgeekss
(B) eksforgeeks
(C) EKSforgeekss
(D) EKSforgeeks
Answer: (A)
Explanation: str.toUpperCase() returns ‘str’ in upper case. But,it does not change the original string ‘str’.
str.substring(x, y) returns a string from position ‘x'(inclusive) to position ‘y'(exclusive).
str.charAt(x) returns a character at position ‘x’ in the string ‘str’.
Quiz of this Question
Recommended Posts:
- Java | Functions | Question 6
- Java | Functions | Question 10
- Java | Functions | Question 9
- Java | Functions | Question 5
- Java | Functions | Question 4
- Java | Functions | Question 8
- Java | Functions | Question 3
- Java | Functions | Question 2
- Java | Functions | Question 7
- Java | Functions | Question 1
- Currying Functions in Java with Examples
- C | Functions | Question 11
- C | Functions | Question 8
- C | Functions | Question 9
- C | Functions | Question 10
Improved By : Vijay Sirra



