• Verkeerd document? Gratis ruilen
  • Geschreven door studenten die geslaagd zijn
  • Direct beschikbaar na je betaling
  • Online lezen of als PDF
Verkopen
Kies je studieland
Kies je taal
Document preview thumbnail
Voorbeeld 2 van de 6 pagina's
Samenvatting

Summary Character and strings sum

Document preview thumbnail
Voorbeeld 2 van de 6 pagina's

Making Java easier for IEB students

Voorbeeld van de inhoud

ddStatic vs Non-static Methods:


What is a Non-Static Method?
• A non-static method is a method that we say “belongs to
the object”
• When you instantiate (create) a new object, a chunk of RAM
gets reserved and copies of all the parent methods (and
fields) are written into that space.
• Each object has inherited its own set of methods (this is one
of the foundations of OOP)
• The Gogga object has its own copy of move(), setDirection(),
etc
• ALL of these inherited methods are non-static methods
• You call a non-static method by using the object name
(Gogga bob = new Gogga();
bob.setPosition(5,7);)
What is a Static Method?
• A method that is “global” it is common to all objects.
• Not every object can inherit its own copy of such a method.
• Single instance of this method is held instead by the class
• Static method “belongs” to the class
• ALL the Gogga object that we create sit on the same grid
• setGridSize() method is static because ALL Goggas use the
same Grid
• You call static methods by calling their class name and also
the String class (char upperChar =
Character.to.UperCase(‘a’);)
How Does this Idea Extend to Fields?
• Fields (and even classes) can also be static or non-static
• A class called Dog(), that will create new instances of dog
objects each time it is invoked(run/executed)

, • numberOfLegs field is ALWAYS going to be 4. So, there is
no need for every dogs to have it’s own copy of this field
• It is better for Class Dog() to have single, static field, that
the individual objects would then just reference if needed
• But hairColour would be non-static field, because dogs have
a wide variety of different colours. So, each object would
need its own copy of this field
• Non-static field, or fields that belong to an instance of a
class (an object), are also sometimes known as “instance
variables”


Method Declarations, Headers and Signatures:
What is a Method Declaration?
• The method declaration is the whole bang-shoot, The
entire method.
What is a Method Header?
• The first line of the method declaration.
What is the Method Signature?
• The method name and any parameters.
Related Terminology:
• public: is the access modifier
• static: specifies if the method belongs to the class, or
object of the class
• void/othertypes: this is the types of data that the
method returns


Characters have value:

Documentinformatie

Schooljaar
200
Geüpload op
19 februari 2025
Aantal pagina's
6
Geschreven in
2024/2025
Type
Samenvatting
€6,27

Verkeerd document? Gratis ruilen Binnen 14 dagen na aankoop en voor het downloaden kun je een ander document kiezen. Je kunt het bedrag gewoon opnieuw besteden.
Geschreven door studenten die geslaagd zijn
Direct beschikbaar na je betaling
Online lezen of als PDF

Verkocht
0
Volgers
0
Items
1
Laatst verkocht
-

Echte notities, van echte studenten
Elk document op Stuvia is geschreven door een medestudent die hetzelfde vak deed. Zo leer je van iemand die het al heeft gehaald.



Waarom studenten kiezen voor Stuvia

Gemaakt door medestudenten, geverifieerd door reviews

Kwaliteit die je kunt vertrouwen: geschreven door studenten die slaagden en beoordeeld door anderen die dit document gebruikten.

Niet tevreden? Kies een ander document

Geen zorgen! Je kunt voor hetzelfde geld direct een ander document kiezen dat beter past bij wat je zoekt.

Betaal zoals je wilt, start meteen met leren

Geen abonnement, geen verplichtingen. Betaal zoals je gewend bent via iDeal of creditcard en download je PDF-document meteen.

Student with book image

“Gekocht, gedownload en geslaagd. Zo makkelijk kan het dus zijn.”

Alisha Student

Bezig met je bronvermelding?

Maak nauwkeurige citaten in APA, MLA en Harvard met onze gratis bronnengenerator.

Bezig met je bronvermelding?

Veelgestelde vragen