100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached 4.2 TrustPilot
logo-home
Summary

Summary Character and strings sum

Rating
-
Sold
-
Pages
6
Uploaded on
19-02-2025
Written in
2024/2025

Making Java easier for IEB students

Institution
Course









Whoops! We can’t load your doc right now. Try again or contact support.

Written for

Institution
Course
Schooljaar
200

Document information

Uploaded on
February 19, 2025
Number of pages
6
Written in
2024/2025
Type
Summary

Subjects

Content preview

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:
$7.07
Get access to the full document:

100% satisfaction guarantee
Immediately available after payment
Both online and in PDF
No strings attached

Get to know the seller
Seller avatar
sangeengxonono

Get to know the seller

Seller avatar
sangeengxonono
Follow You need to be logged in order to follow users or courses
Sold
0
Member since
9 months
Number of followers
0
Documents
1
Last sold
-

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Frequently asked questions