Level 117 Level 119
Level 118

[Quiz] Abstraction

27 words 0 ignored

Ready to learn       Ready to review

Ignore words

Check the boxes below to ignore/unignore words, then click save at the bottom. Ignored words will never appear in any learning session.

All None

What is a group of related methods with empty bodies?
An object of a particular class. In programs written in the Java programming language, an instance of a class is created using the new operator followed by the class name.
An abstract method is a method that is declared without implementation (no braces).
a program component that uses a class is called a client of the class
invoking a method
write the name of the RECEIVING OBJECT first, followed by a DOT, then the NAME of the method to be invoked, and finally a set of parentheses that contain the ARGUMENTS
local variable
A variable known only within a method or a small program structure, such as loop structure or conditional structure
Indicates that a variable or method belongs to a class, rather than to any object created from the class.
describes the way an object or variable my be treated in different contexts as though it was a different type. For example: inheritance allowes an argument of type B to be passed to a param…
Defines the behaviour required from a class without specifying its implementation. Defined like a class but only includes *automatically public* method headers and constants. E.g. 'public interface Comparable<T> { int compareTo(T o); } ' …
interface constants
implicitly declared as public static final so don't need to be declared as such.
'implements' Keyword
specifies that a class conforms to the interface and forces a class to provide method bodies for the abstract methods in an interface that it implements. E.g. 'class Bird implements FlyingAnimal { ... }'
Comparable Interface
generic interface that allows objects of a class to be compared and returns a value depending on which is 'larger' as defined by the implementing class. compareTo(T o) Returns 0 for equality, >0 if…
java.util.Arrays.sort(Object [] oa)
a static method used to sort the supplied array by making use of objects that implement the Comparable<T> generic interface. A good example of how interfaces can be used to write general purpose code.
Interface References
Although it isn't possible to construct an object from an interface, it is possible to create a reference variable for any object whose class implements that interface.
generic 'Iterator<E>' interface
Requires implementation of hasNext() (more elements ?), next() (return reference to next element) and remove() (remove element previously returned by next()). Iterator objects are accessed/created by collections and disposed of once used. Further iterations require new iterator objects.
Deleting items from a collection
requires the use of an iterator and its method remove(). This is considered the safest / most efficient way *whilst* the collection is being iterated, rather than using a 'for-each' statement which should just be used for iteration.
interfaces extending interfaces
possible through the use of the 'extends' keyword. E.g. 'public interface AttackingFlyingAnimal extends FlyingAnimal {..}' Unlike classes, Interfaces can extend *multiple interfaces* with 'extends' and comma separation. So multiple-inheritance is sort of possible..
Specialisation & Abstraction
classes become more specialised as you move from top to bottom in a class hierarchy. Eventually classes at the top may become so general that there is no need to instantiate objects of their t…
keyword 'abstract'
used to define a class or method as abstract. An abstract class can't be used to construct an object and an abstract method has no body, it must be implemented by its subclass. E.g. 'pu…
private constructor
a way of making sure that no other object can construct an object from a class. Perhaps the class itself will have a static method that can return objects that it creates itself (factory patte…
polymorphism OO definition
The ability of an interface to be realized in multiple ways. *many forms*. Put into practise during dynamic binding of overridden methods depending on actual object type.
has-a class relationship
whereby one object of a class contains an object of another class, ie. it is a composite object and the relationship is that one has the other.
has-a Vs is-a
has-a describes relationships between objects where one contains another. is-a describes a relationship between classes where one inherits from another. However what applies to objects maps to classes and vice-versa.
choosing is-a relationship
applies when one class is a specialisation of another. Inheritance should be chosen for this reason but not just for the sake of code re-use. Inheritance relationships are easier for a programmer to follow than composition.
choosing has-a relationship.
use when one class needs to make use of another. Composition is more flexible than inheritance but the relationships are difficult to follow (part of a network rather than a hierarchy).
Useful for efficient storage and retrieval of *sorted* data.
LinkedList indexes
it is possible to access a linked list by index (e.g to insert or remove an item). E.g. by using the methods 'E remove(int index);' or 'void add(int index, E el);'. Note that this m…