Types Of Rules For Static

Submitted By JohannCABJ
Words: 500
Pages: 2

Yes, let's start this off. Post made public and pinned. Rules for static:
1. A static method cannot see/use non-static attributes/methods of a class.
2. Only a static method/attribute can be called on the class (without an object)
3. A static attribute is shared amongst all objects of that type (including children types) Rules for visibility:
1. Anyone can see something that is public.
2. Only the class can see something private.
3. Child classes make room in memory for private attributes, though they cannot access them directly. Rules for inheritance:
1. Everything is inherited, but only public things can be accessed directly.
2. If a method foo is overloaded on the inheritance hierarchy, and we do x.foo(). Dynamic binding uses the runtime type of the object x to walk up the inheritance hierarchy to find the foo() method with the same signature that is closest to the runtime type of x.
3. super can be used to access anything public in the parent class only.
4. A child type can be assigned to a parent variable, but not the other way around. Abstract classes and interfaces
1. An abstract class cannot be directly instantiated (only a child class may call the ctor through super)
2. If a type has an abstract method, it cannot be a concrete class Interfaces
1. To implement an interface, all its methods must have bodies. Otherwise, the implementing class must be abstract.
2. Interfaces can be extended with other interfaces. Exceptions
1. Only checked exceptions must be in try-catch blocks.
2. An exception creates an object in memory
3. For an exception to be caught, the line of code generating the exception must be in a try block somewhere along the call chain.
...

General rules
1. Casting does not change the type of memory.
2. Method arguments and local