MCQHard1 mark
1
Choose the correct answers to the questions from the given options. (Do not copy the questions, write only the correct answers.)
String a[] = {"Atasi", "Aditi", "Anant", "Amit", "Ahana"}; System.out.println(a[1].charAt(1) + "*" + a[2].charAt(2)); The output of the above statement is:
Topic: charAt() on an array of Strings
Previous-year question practice database
Try it
Pick an option and check your answer. The full worked answer is below either way.
Answer
Exam answer
(b) d * a.
Explanation
Take it in two steps. a[1] is "Aditi" and charAt(1) gives its second character, 'd'. a[2] is "Anant" and charAt(2) gives its third character, 'a'. Now the joining: because "*" is a String, the + operator concatenates rather than adds, so the chars are converted to text and the result is d*a. The paper prints it with spaces as d * a. Had the "*" not been there, the two chars would have been ADDED as ASCII values instead.
In words
d * a.
More from String Manipulation
To extract the word NOW from the word "ACKNOWLEDGEMENT", the Java statement "ACKNOWLEDGEMENT".substring(3, ____) is used. Choose the correct number to fill in the blank.2026Which of the following String methods returns a negative value?2026Assertion (A): The substring() method modifies the original String.
Reason (R): The substring() method can extract part of a String starting from a specific index.2026Give the output of the following program segment:
String S = "GRACIOUS".substring(4);
System.out.println(S);
System.out.println("GLAMOROUS".endsWith(S));2026Name the following:
(a) The return data type of the method equals().
(b) The String method which has no parameter and returns a String.2026Write a program to accept a word and print the Symbolic of the accepted word.
Symbolic word is formed by extracting the characters from the first consonant, then add characters before the first consonant of the accepted word and end with "TR".
Example: AIRWAYS - Symbolic word is RWAYSAITR
BEAUTY - Symbolic word is BEAUTYTR2026