Hey there! Prepping for the Java exam at VU Amsterdam? I've got you covered! I've summarized everything from this year's completely overhauled course, capturing all the crucial info from the slides. Whether you're refreshing old concepts or grappling with the new stuff, this guide is your ticket t...
, 1 Modifiers
In Java, modifiers are keywords added to class, method, or variable definitions
to change their meanings. They play a pivotal role in adjusting the behaviour
and visibility of various elements like fields, classes, methods, and variables.
Broadly, modifiers can be categorised into two groups:
• Access Modifiers: Such as public and private, which control the
visibility of classes, methods, and variables.
• Non-Access Modifiers: Like final and static, which provide other
functionalities.
When a variable is designated as final, it means that once a value is
assigned to it, it cannot be altered. This immutability ensures data consis-
tency and integrity. It’s essential to assign a value to a final variable either
directly or via the constructor.
1.1 Illustrative Example:
For instance, consider a class Individual where the yearOfBirth is marked
as final. Once an Individual object is created with a specific birth year, it
cannot be changed.
1 class Individual {
2 final int yearOfBirth ;
3 Individual ( int yearOfBirth ) {
4 this . yearOfBirth = yearOfBirth ;
5 }
6 }
Listing 1: Final variable example in Java
In the advanced programming landscape, terms like public, static, and
final hold special significance. Specifically:
• public ensures universal accessibility.
• static indicates the element belongs to the class rather than any in-
stance.
• final denotes immutability.
4
The benefits of buying summaries with Stuvia:
Guaranteed quality through customer reviews
Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.
Quick and easy check-out
You can quickly pay through credit card or Stuvia-credit for the summaries. There is no membership needed.
Focus on what matters
Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!
Frequently asked questions
What do I get when I buy this document?
You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.
Satisfaction guarantee: how does it work?
Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.
Who am I buying these notes from?
Stuvia is a marketplace, so you are not buying this document from us, but from seller cedm9. Stuvia facilitates payment to the seller.
Will I be stuck with a subscription?
No, you only buy these notes for $16.51. You're not tied to anything after your purchase.