levo

Defining Data: Types, Variables and Classes

Attributes and the properties of a class

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

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.

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