5.4 Flashcards
Method & Method Signature
textbook definiton:
A signature includes the name of the method, as well as its parameters, their number and types. Return types are not considered part of the signature.
A method is a set of code which is referred to by name and can be called (invoked) at any point in a program simply by utilizing the method’s name.
– Procedures: don’t return any value (void).
– Functions: return a value
Mod vs Div
Mod gives you mathemtical remainder
Div: gives you the number of times A fits into B. So exappe 5 Div 14 = 2, with a mod of 4 (remander )
Private, protected, public, extends, static , extends
Public: A class, method, field or constructor that is declared public can be accessed from any other class.
Private: Methods, variables, and constructors that are declared private can only be accessed within the declared class itself.
Protected:
Variables, methods, and constructors, which are declared protected in a superclass can be accessed only by the subclasses in any class within the package of the protected members’ class.
extends is the keyword used in a sub class to inherit the properties of a super class
The static keyword in Java means that the variable or function is shared between all instances of that class as it belongs to the class, not the actual objects themselves.
So if you have a variable: private static int i = 0; and you increment it ( i++ ) in one instance, the change will be reflected in all instances
Private, protected, public, extends, static , extends
Public: A class, method, field or constructor that is declared public can be accessed from any other class.
Private: Methods, variables, and constructors that are declared private can only be accessed within the declared class itself.
Protected:
Variables, methods, and constructors, which are declared protected in a superclass can be accessed only by the subclasses in any class within the package of the protected members’ class.
extends is the keyword used in a sub class to inherit the properties of a super class
The static keyword in Java means that the variable or function is shared between all instances of that class as it belongs to the class, not the actual objects themselves.
So if you have a variable: private static int i = 0; and you increment it ( i++ ) in one instance, the change will be reflected in all instances