levo

Defining Data: Types, Variables and Classes

Attributes and the properties of a class

  • 3 things to know
  • AS Unit 1

Overview

Attribute of a class, saying that attributes represent the properties of a class and instance attribute.

What you need to know

Answer each one before you reveal it.

Your recallNot started
Key term

Why must every attribute be declared with a type?

Key term

What is the difference between the attributes of a class and the values held by one object?

Key term

What is meant by saying that attributes represent the properties of a class?

Questions from this subtopic

Each one with the model answer underneath.

  1. 1

    What is an attribute of a class?

    Model answer

    An attribute is a named data item declared in a class, of a stated type, whose value describes one characteristic of an object of that class.

  2. 2

    What is meant by saying that attributes represent the properties of a class?

    Model answer

    Each attribute names one property that every object of the class possesses, so the list of attributes is a statement of what the class knows about itself.

  3. 3

    How does an attribute differ from a method?

    Model answer

    An attribute stores a value that describes an object, whereas a method is a block of code defining something the object can do.

  4. 4

    Why must every attribute be declared with a type?

    Model answer

    The declared type fixes how much memory the attribute needs, which values are legal in it and which operations may be applied, so the compiler can reject nonsense such as multiplying a name by a date.

  5. 5

    For a class Pupil, name four sensible attributes and give a suitable type for each.

    Model answer

    Suitable attributes are name held as a String, dateOfBirth held as a date type, yearGroup held as an int, and hasPaidFees held as a boolean.

  6. 6

    A class Product must store a price. Recommend a type and justify the recommendation.

    Model answer

    A price is best held as a whole number of pence in an integer type, or in a decimal type designed for currency, because a double introduces rounding errors that accumulate across a bill.

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 Defining Data: Types, Variables and Classes, 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.