levo

Objects, Classes and Data Structures

Strings and string handling

  • 3 things to know
  • AS Unit 1

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.

What is inside Levo

Six ways to work the same material.

1Closed book
2Open book
3Closed book

The 3-step method, run for you

Answer cold, learn it, then prove it stuck. Levo tracks the jump between your first attempt and your last.

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

Cram a whole paper in one sitting

Sort every topic into what you know and what you do not, then drill only the weak ones.

A null is the of one.
absencepresencetype

Blank Blitz makes facts automatic

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

AA null means no value has been recorded.
BZero and an empty string are values.
CA null is the absence of a value.

Build It gets the exam shape right

Assemble a full-mark answer from its marking points, in the order an examiner wants them.

An error is the mistake a person made.
TrueFalse

Test It catches misconceptions

Spot the fault in a statement. The traps are the mistakes students actually make.

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.

Attempt a question from memory, write the correct version, then attempt it again. Levo records the jump between your first attempt and your last, and brings each question back on the day you are due to forget it.

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