SlideShare a Scribd company logo
JAVA MODIFIERS
Talk 12
ACCESS MODIFIERS
• private: only this class	

• protected: subclasses, classes in same package	

• public: every class	

• default: classes in same package
FINAL
• on a field: can be (and needs to be) assigned only
once	

• on a method: cannot be reimplemented	

• on a class: cannot have subclasses
STATIC
• on a field or method: the field or method
belongs to the class (not to the instance)	

• static block: initializes static fields
class Foo {	
private static int baz;	
!
static {	
baz = 10;	
}	
}
TRANSIENT
• on a field: will not persisted during serialization
SYNCHRONIZED
• on a method: can be executed by only a thread at
a time	

• the lock is on the instance on which the method is
invoked
VOLATILE
• on a field: tells the compiler that the field can be
modified unexpectedly by another thread;	

• it is not stored in CPU caches.

More Related Content

PPTX
Access modifiers in java
PPT
Java access modifiers
PPTX
Java Access Specifier
PPTX
Javasession8
PDF
Oops (inheritance&interface)
PPT
Core java
PPTX
Concurrency
Access modifiers in java
Java access modifiers
Java Access Specifier
Javasession8
Oops (inheritance&interface)
Core java
Concurrency

Similar to 12 java modifiers (19)

PDF
01-class-and-objects java code in the .pdf
PDF
Chapter 03 enscapsulation
PPT
Inheritance and Polymorphism
PPTX
Chap1 packages
PPTX
Nested classes in java
PPTX
Java Nested class Concept
PPT
Java inheritance concept, interface, objects, extends
PPT
04 inheritance
PPT
04_inheritance power point presentation.
PPT
inheritance
PDF
OSGi and Java 9+
PDF
OSGi and Java 9+ - BJ Hargrave (IBM)
PPTX
Unit II Inheritance ,Interface and Packages.pptx
PPTX
Java session2
PPTX
Java Platform Module System
PPT
Inner classes9 cm604.28
PPTX
27csharp
PPTX
PPTX
OBJECT ORIENTED PROGRAMMING Unit2 second half.pptx
01-class-and-objects java code in the .pdf
Chapter 03 enscapsulation
Inheritance and Polymorphism
Chap1 packages
Nested classes in java
Java Nested class Concept
Java inheritance concept, interface, objects, extends
04 inheritance
04_inheritance power point presentation.
inheritance
OSGi and Java 9+
OSGi and Java 9+ - BJ Hargrave (IBM)
Unit II Inheritance ,Interface and Packages.pptx
Java session2
Java Platform Module System
Inner classes9 cm604.28
27csharp
OBJECT ORIENTED PROGRAMMING Unit2 second half.pptx
Ad

More from Federico Russo (20)

PDF
23 Sicurezza in BBox
PDF
21 Buzzwords
PDF
18 - InfluxDB
PDF
19 - The Highlander Project
PDF
22 - Better Coding
PDF
20 - Ottimizzare le query
PDF
17 - Web Application Threats
PDF
16 - Project Lombok
PDF
15 - Java 8
PDF
14 - Atom
PDF
Slides functionalities 0.26-r16
PDF
BBox e vaadin7
PDF
Box Functionalities 0.20
PDF
Tile server
PDF
PDF
10 Data caching
PDF
11 Java 7
PDF
08 Workflow e strumenti web
PDF
06 Refactoring
PDF
09 Transactions
23 Sicurezza in BBox
21 Buzzwords
18 - InfluxDB
19 - The Highlander Project
22 - Better Coding
20 - Ottimizzare le query
17 - Web Application Threats
16 - Project Lombok
15 - Java 8
14 - Atom
Slides functionalities 0.26-r16
BBox e vaadin7
Box Functionalities 0.20
Tile server
10 Data caching
11 Java 7
08 Workflow e strumenti web
06 Refactoring
09 Transactions
Ad

Recently uploaded (20)

PPTX
Odoo POS Development Services by CandidRoot Solutions
PDF
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
PDF
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
PDF
PTS Company Brochure 2025 (1).pdf.......
PDF
AI in Product Development-omnex systems
PDF
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
PDF
Odoo Companies in India – Driving Business Transformation.pdf
PDF
Digital Strategies for Manufacturing Companies
PPTX
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
PDF
top salesforce developer skills in 2025.pdf
PDF
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
PDF
How to Choose the Right IT Partner for Your Business in Malaysia
PDF
How to Migrate SBCGlobal Email to Yahoo Easily
PPTX
Essential Infomation Tech presentation.pptx
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
PPTX
L1 - Introduction to python Backend.pptx
PDF
Wondershare Filmora 15 Crack With Activation Key [2025
PDF
Understanding Forklifts - TECH EHS Solution
PDF
Design an Analysis of Algorithms II-SECS-1021-03
Odoo POS Development Services by CandidRoot Solutions
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
PTS Company Brochure 2025 (1).pdf.......
AI in Product Development-omnex systems
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
Odoo Companies in India – Driving Business Transformation.pdf
Digital Strategies for Manufacturing Companies
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
Adobe Illustrator 28.6 Crack My Vision of Vector Design
top salesforce developer skills in 2025.pdf
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
How to Choose the Right IT Partner for Your Business in Malaysia
How to Migrate SBCGlobal Email to Yahoo Easily
Essential Infomation Tech presentation.pptx
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
L1 - Introduction to python Backend.pptx
Wondershare Filmora 15 Crack With Activation Key [2025
Understanding Forklifts - TECH EHS Solution
Design an Analysis of Algorithms II-SECS-1021-03

12 java modifiers

  • 2. ACCESS MODIFIERS • private: only this class • protected: subclasses, classes in same package • public: every class • default: classes in same package
  • 3. FINAL • on a field: can be (and needs to be) assigned only once • on a method: cannot be reimplemented • on a class: cannot have subclasses
  • 4. STATIC • on a field or method: the field or method belongs to the class (not to the instance) • static block: initializes static fields class Foo { private static int baz; ! static { baz = 10; } }
  • 5. TRANSIENT • on a field: will not persisted during serialization
  • 6. SYNCHRONIZED • on a method: can be executed by only a thread at a time • the lock is on the instance on which the method is invoked
  • 7. VOLATILE • on a field: tells the compiler that the field can be modified unexpectedly by another thread; • it is not stored in CPU caches.