levo

Objects, Classes and Data Structures

Strings and string handling

  • 3 things to know
  • AS Unit 1
Start revising · £5/month

Overview

A string as a sequence of characters counted from zero, length, extracting a substring, searching for one string inside another, joining strings, and why two strings are compared by value rather than by identity.

What you need to know

Answer each one before you reveal it.

Your recallNot started
Key term

Why is a string regarded as a data structure?

Key term

What is the index of the first character of a Java string?

Key term

A program holds String s = "Systems";. What does System.out.println(s.length()); print?

Questions from this subtopic

Each one with the model answer underneath.

  1. 1

    What is a string?

    Model answer

    A string is a sequence of characters stored and handled as a single value, with each character occupying a numbered position within the sequence.

  2. 2

    Why is a string regarded as a data structure?

    Model answer

    A string keeps its characters in order and allows each one to be reached by position, so the characters can be counted, searched and copied in sections.

  3. 3

    What is the index of the first character of a Java string?

    Model answer

    The first character of a Java string sits at index 0, so a string uses indices from 0 up to one less than its length.

  4. 4

    A program holds String s = "Systems";. What does System.out.println(s.length()); print?

    Model answer

    The word Systems is made of the seven characters S, y, s, t, e, m and s, so the statement prints 7.

  5. 5

    A program holds String s = "Systems";. What does System.out.println(s.charAt(2)); print?

    Model answer

    Counting from index 0, S is at 0, y is at 1 and s is at 2, so the statement prints the letter s.

  6. 6

    A program holds String t = "Development";. What does System.out.println(t.substring(0, 7)); print?

    Model answer

    The method copies from index 0 and stops before index 7, taking the seven characters D, e, v, e, l, o and p, so the statement prints Develop.

Other ways to work this

The same content, four other ways.

Everything in your subscription

Runs, plus a mode for every other kind of session.

1Flash
2Imposter
3Fade
4Brain dump

Learn every subtopic in runs of four questions

Facts flash and fade, a wrong word hides in some of them, and a brain dump decides which questions are locked in.

Software and the Development Environment
Defining Data: Types, Variables and Classes
Program Control Structures
Objects, Classes and Data Structures

Cram the night before, weakest topic first

A quick scan finds your weakest topics. Recall each fact you missed three times in a row.

A null is the of one.
absencepresencetype

Blank Blitz consolidates the facts

Rapid timed gap-fills on the terms and numbers you need to recall without thinking.

✓What it iscovered
~Why it happenspartly there
How long it lastsnot there yet

Explain It tests your understanding

Explain a concept in your own words and see which of its points you covered.

An error is the mistake a person made.
TrueFalse

Test It catches misconceptions

Spot the fault in a statement. The faults are the mistakes students make most often.

721941163128510

Brain Breaks between sessions

Short focus games to reset attention, so the next set lands better than the last.

Every question in Objects, Classes and Data Structures, on a schedule.

Learn it in runs of four questions, each ending on a brain dump against the clock. Every question you lock in comes back the next day, then at longer gaps, each time just before you would forget it.

Or £46 a year, about £3.83 a month. Cancel anytime.