• Wrong document? Swap it for free
  • Written by students who passed
  • Immediately available after payment
  • Read online or as PDF
Sell
Where do you study
Your language
Document preview thumbnail
Preview 4 out of 34 pages
Summary

Summary Java ,String

Document preview thumbnail
Preview 4 out of 34 pages

This document would provide you the best interest in java computer language for understanding of Strings.

Content preview

STRING HANDLING
Concepts & Advanced Question Bank


ICSE Class 10 • Computer Applications • Chapter 8




Refined notes · board-style hard questions · full worked Java solutions




Built for board, pre-board, unit test and last-minute revision

,Table of Contents

PART 1 — CONCEPT NOTES 3

1.1 Three Ways to Handle Character Data . . . . . . . . . . . . . . . . . . . . . . . . .3

1.2 Creating String Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

1.3 The Immutability Rule . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

1.4 Creating StringBuffer Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

1.5 String vs StringBuffer — The Comparison Board Loves . . . . . . . . . . . . . . . . . 4

1.6 String Class Methods — Full Reference . . . . . . . . . . . . . . . . . . . . . . . . . 5

1.7 StringBuffer Methods & Chaining . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6

1.8 length() vs capacity() — The Efficiency Story . . . . . . . . . . . . . . . . . . . . . . 7

1.9 Six Traps Every Topper Falls For . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7



PART 2 — QUESTION BANK 9

2.1 Section A — Objective Type (Hard) . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

2.2 Section A2 — Short Answer Theory (2 Marks Each) . . . . . . . . . . . . . . . . . . 11

2.3 Section B — Output-Based / Program Tracing (Hard) . . . . . . . . . . . . . . . . . 13

2.4 Section C — Programming Questions (Complex & Board-Style) . . . . . . . . . . . . 16



PART 3 — RAPID REVISION 33

3.1 One-Page Method Cheat Sheet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33

3.2 Common Mistakes — Quick List . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33

3.3 Last-Minute Formula Box . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34

,String Handling — Concepts & Question Bank ICSE Class 10 • Computer Applications




PART 1 — CONCEPT NOTES
A tight, exam-focused pass through Chapter 8 before you get to the question bank. Every trap that shows up
in Part 2 is flagged here first.




▌ 1.1 Three Ways to Handle Character Data
Java gives you three tools for character data, and board papers expect you to know which one
fits which job:

– char / Character — a single character (Character is the wrapper class around char).
– String — a sequence of characters that is immutable (cannot be changed after creation).
– StringBuffer — a sequence of characters that is mutable (can be edited in place).


● ADDITIONAL INFO
Both String and StringBuffer live in java.lang, which is imported automatically — you never
need an explicit import statement for either one.




▌ 1.2 Creating String Objects
There are two ways to create a String:

String name = "I am a student"; // (i) string literal
String copy = new String("Hello"); // (ii) using the new operator
String empty = new String(); // an empty string


Three features you can be asked to state directly: a String stores characters accessible by index,
it offers methods for concatenation/comparison/searching, and — most importantly — it is
immutable.


▌ 1.3 The Immutability Rule
A classic board trap: this code compiles and runs with no error, even though String is immutable.

String city = "Delhi";
city = "Mumbai"; // no error!


Java does not edit the "Delhi" object. It quietly builds a brand-new String object holding "Mumbai"
and re-points the reference variable city to it. The old "Delhi" object still exists in memory, just
unreachable.




1

, String Handling — Concepts & Question Bank ICSE Class 10 • Computer Applications




Fig. 1 — Immutability: a new object is created, the reference simply moves.



★ MUST REMEMBER
"Immutable" means the object’s content never changes — it says nothing about whether the
variable can be reassigned to point elsewhere.




▌ 1.4 Creating StringBuffer Objects
StringBuffer objects are always built with new — there is no literal shorthand. Three constructors
are examinable:

StringBuffer sb1 = new StringBuffer(); // empty, default capacity 16
StringBuffer sb2 = new StringBuffer("First"); // holds "First", capacity = 5 + 16 = 21
StringBuffer sb3 = new StringBuffer(15); // empty, capacity fixed at 15



Constructor What it does

new StringBuffer() Empty buffer, default capacity of 16 characters.

new StringBuffer("txt") Buffer pre-loaded with "txt"; capacity = length("txt") + 16.

new StringBuffer(n) Empty buffer with capacity fixed at n — avoids repeated reallocation if you
already know roughly how big the content will get.



▌ 1.5 String vs StringBuffer — The Comparison Board
Loves




2

Document information

School year
1
Uploaded on
July 30, 2026
Number of pages
34
Written in
2025/2026
Type
Summary
$10.99

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Sold
0
Followers
0
Items
2
Last sold
-



Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions