0% found this document useful (0 votes)
4 views2 pages

Java String Worksheet Class10 ICSE

This document is a worksheet for ICSE Class 10 Computer Applications focusing on Strings in Java, consisting of multiple choice questions, short answer questions, and programming tasks. It covers various string methods, their functionalities, and differences between string types. The total marks for the worksheet are 40, with a time limit of 45 minutes.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views2 pages

Java String Worksheet Class10 ICSE

This document is a worksheet for ICSE Class 10 Computer Applications focusing on Strings in Java, consisting of multiple choice questions, short answer questions, and programming tasks. It covers various string methods, their functionalities, and differences between string types. The total marks for the worksheet are 40, with a time limit of 45 minutes.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

ICSE Class 10 – Computer Applications

Worksheet on: Strings in Java


Total Marks: 40 Time: 45 min

Section A – Multiple Choice Questions (1 × 14 = 14 Marks)


1. Which of the following is a valid way to create a string in Java?
a) String s = 'Hello'; b) String s = "Hello"; c) String s = new String('Hello');
d) String s = Hello;
2. Which method returns the length of a string?
a) getSize() b) length() c) size() d) count()
3. What is the output of "HELLO".toLowerCase();
a) HELLO b) hello c) Hello d) Error
4. The index of the first character in a Java String is:
a) -1 b) 0 c) 1 d) None of these
5. Which of these methods compares two strings ignoring the case?
a) equals() b) compareTo() c) equalsIgnoreCase() d) compareIgnoreCase()
6. 6. What does the method charAt(3) return for the string "PROGRAM"?
a) G b) R c) O d) GRA
7. The method substring(2,5) returns:
a) Characters from index 2 to 5 b) Characters from index 2 to 4
c) Characters from index 3 to 5 d) None of these
8. Which method is used to find the position of a character in a string?
a) charAt() b) indexOf() c) find() d) position()
9. What will be the output of "Java".concat("Program")?
a) Java Program b) JavaProgram c) ProgramJava d) Error
10. Which statement is true about strings in Java?
a) Strings are mutable. b) Strings are immutable.
c) Strings can be modified directly. d) Strings are numeric.
11. What will "hello".compareTo("HELLO") return?
a) 0 b) Positive value c) Negative value d) Error
12. Which of these is not a valid String method?
a) startsWith() b) endsWith() c) reverse() d) trim()
13. What is the output of " Java ".trim();
a) " Java " b) "Java" c) " Java " d) Error
14. "computer".replace('c','C') will give:
a) Ccomputer b) Computer c) CComputer d) cComputer

Section B – Short Answer Questions (2 × 7 = 14 Marks)


1. What is the difference between String and StringBuffer in Java?
2. Explain the use of indexOf() and lastIndexOf() methods with an example.
3. Write the output of the following:
String s = "ICSEJava";
[Link]([Link](2,6));
4. Differentiate between equals() and == operator in context of Strings.
5. What is the purpose of the toUpperCase() and toLowerCase() methods?
6. Write a statement to extract the last character of a string variable name.
7. What is meant by immutable nature of strings in Java?
Section C – Programming Questions (2 × 6 = 12 Marks)
1. Write a program to input a string and count the number of vowels and consonants present in
it.
Example:
Input: Hello World
Output:
Vowels = 3
Consonants = 7

2. Write a program to input a string and check whether it is a palindrome or not.


Example:
Input: LEVEL
Output: Palindrome String

You might also like