Thread class | has definition A Java class that implements the general concept of a thread | |
has specification | |
has methods start, run, interrupt, sleep, yield, join, stop (deprecated), suspend (deprecated) | |
implements the Runnable interface | |
is a member of the java.lang package | |
is a subtopic of Example Classes | |
is a subtopic of Threads | |
is an instance of class | |
see also thread | |
class | | |
| |
| |
| |
| |
adds 0 or more variables to the variables it inherits from its superclass | |
adds 0 or more methods to the methods it inherits from its superclass | |
can access any public class in other packages | |
can be imported from a package | |
can extend only one superclass | |
can override methods that are inherited from the class's superclass | |
can protect its members from access by other classes or objects using an access modifier | |
cannot inherit method implementations from an interface | |
contains all of the code that relates to its objects including | |
contains data associated with each object | |
declares a list of variables, called instance variables, corresponding to data that will be present in each instance | |
defines | |
defines a class type whose instances are the values of the class type | |
has benefit | |
has example public class HelloWorld { public static void main(String[] args) { System.out.println("Hello World!"); } } | |
has part class name | |
has part code | |
has part constructor | |
has syntax class classname { // declarations of variables // declarations of constructors // declarations of other methods with public ones first } | |
inherits 0 or more methods from its superclass | |
inherits 0 or more variables from its superclass | |
inherits behaviour from its superclass | |
is abstract if it has one or more abstract methods | |
is the unit of data abstraction in an object-oriented program | |
is a descendant of Object class | |
is specified by 1 class definition | |
may have access modifier | |
provides implementation for all its instance methods unless the class is abstract | |
represents several similar objects | |
should be named after a thing its instances represent in the real world | |
should be placed in its own source file | |
should not be named after the internals of a computer system such as 'Record', 'Table', 'Data', 'Structure', or 'Information' | |
should order elements as follows: - class variables
- instance variables
- constructors
- the most important public methods
- methods that are simply used to access variables
- private methods
| |
to instantiate you create an instance of it | |
uses an implements clause to declare that it contains methods for each of the operations specified by the interface | |
access unit | has access mode | |
syntactic unit | has syntax rule bold = mandatory italic = non-terminal normal font = optional | |