Creating Classes (Terminology) Flashcards
class vs object?
Class: The blueprint
Object: The product of the blueprint (house)
toString method?
Automatically is used when a programmer writes the following in their driver: print() and println() -The toString() method by default is limited so it is recommended that each created class have a custom toString() method so we can control the output when our class is called on.
toString method?
toString() method is Automatically used when a programmer writes the following in their driver: print() and println() -The toString() method by default has limitations, so it is recommended that each class we create have a custom toString() method so we can control the output when our class methods are called on. nameofObject.nameOfMethod();
class vs object?
Class: is the blue print of the object– Basically the Class is the instruction that takes place to create an object?
so class = blueprints
Object:
object= house built out of those blueprints.
toString method?
= The format that our output will print to.
toString() method is Automatically used when a programmer writes the following in their driver: print() and Syste,.out.println() -The toString() method by default has limitations, so it is recommended that each class we create have a custom toString() method so we can control the output when our class methods are called on. nameofObject.nameOfMethod();
Driver/ Application?
The driver is what runs and produces output to the user. it is what the user interacts with. while the classes are written in another area and are called on. Contains the () main method.
what is an Accessor?
The Accessor gives the driver access to private object values in a secure way so that the driver can not alter the private object.
a method that is written in the class (portion of code) & uses “Public” so that the method can be called on via the driver/ program code.
What is the code format of an Accessor?
can you give an example?
Format:
Public returnTypeLikeString getNewObjectName ()
{ return objectThatIsPrivate; }
Example:
public int getPhoneNumber ( )
{ return phoneNumber; }
^^^^^^^^^^^^^this is a private object within the class.
What is a Method? examples?
Method = class code written where a method name is associated with code (does something). Examples: -mutators, Accessors, constructor ect.
what is a Mutator?
Example?
Mutator: allows another class to change the value of data. example: public void setParts(float cparts) { if (cparts > 0) parts = cparts; } ^ whatever is in the { } is the security check so that bad data cant be assigned when the data is being changed.
what does the return type: void do?
void: does not return data, instead it does work. example: a Mutator is used with void to change a value in a class.