Which method is used to extract a single character from a string in Java?
This section of our 1000+ Java MCQs focuses on character extraction of Java Programming Language. 1. Which of these method of class String is used to extract more than one character at a time a String object? Answer: d 2. Which of these methods is an alternative to getChars() that stores the characters in an array of bytes? Answer: a 3.
In the following Java code, what can directly access and change the value of the variable name? a) any class Answer: c 4. What will be the output of the following Java code?
a) The value “4” is printed at the command line Answer: d 5. Which of these methods can be used to convert all characters in a String into a character array? Answer: c 6. What will be the output of the following Java code?
a) Hello, i love java Answer: d $ javac output.java $ java output llo i l 7. What will be the output of the following Java code?
a) 6 4 6 9 Answer: a $ javac output.java $ java output 6 4 6 9 8. What will be the output of the following Java code?
a) a is a lower case Letter is White space characterb) b is a lower case Letter is White space characterc) a is a lower case Letter A is an upper case Letterd) a is a lower case Letter 0 is a digitView Answer Answer: c $ javac output.java $ java output a is a lower case Letter A is an Upper Case Letter 9. What will be the output of the following Java code?
a) h Answer: b $ javac output.java $ java output e Sanfoundry Global Education & Learning Series – Java Programming Language. Next Steps:
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn. Subscribe to his free Masterclasses at Youtube & technical discussions at Telegram SanfoundryClasses. Which method extracts a single character from a string?The substr() method extracts a part of a string. The substr() method begins at a specified position, and returns a specified number of characters. The substr() method does not change the original string. To extract characters from the end of the string, use a negative start position.
Which function is needed to extract a character from a string in Java?In Java, the charAt() function returns a character at the specified index of a string.
Which method is used to extract a single character at an index?charAt() method is used to extract a single character at an index.
What is charAt () in Java?The charAt() method returns the character at the specified index in a string. The index of the first character is 0, the second character is 1, and so on.
|