SlideShare a Scribd company logo
4
Most read
5
Most read
7
Most read
NAME: DHRUMIL I. PANCHAL
SEM: 5TH SEMESTER
SUBJECT: OBJECT ORIENTED PROGRAMMING WITH JAVA
BRANCH: COMPUTER ENGINEERING (B.E.)
YEAR: 2019-20
Welcome
Topic
This and Static Keyword
Contains
 This Keyword
 Static Keyword
This Keyword
 There can be a lot of usage of java this
keyword. In java, this is a reference
variable that refers to the current object.
Usage of This Keyword
 Here is given the 6 usage of java this keyword.
1. this can be used to refer current class instance variable.
2. this can be used to invoke current class method
(implicitly)
3. this() can be used to invoke current class constructor.
4. this can be passed as an argument in the method call.
5. this can be passed as argument in the constructor call.
6. this can be used to return the current class instance
from the method.
Example
// A redundant use of this.
Box(double w, double h, double d)
{
this. width = w;
this. height = h;
this. depth = d;
}
Static Keyword
 The static keyword in Java is used for memory
management mainly. We can apply static
keyword with variables, methods, blocks
and nested classes. The static keyword belongs
to the class than an instance of the class.
 The static can be:
1. Variable (also known as a class variable)
2. Method (also known as a class method)
3. Block
4. Nested class
Static Variable
 If you declare any variable as static, it is
known as a static variable.
 The static variable can be used to refer to the
common property of all objects (which is not
unique for each object), for example, the
company name of employees, college name
of students, etc.
 The static variable gets memory only once in
the class area at the time of class loading.
Static Method
 If you apply static keyword with any method,
it is known as static method.
1. A static method belongs to the class rather
than the object of a class.
2. A static method can be invoked without the
need for creating an instance of a class.
3. A static method can access static data
member and can change the value of it.
Static Block
 Is used to initialize the static data member.
 It is executed before the main method at the
time of class loading.
Reference
 Inspiration from Prof. Milin Patel and Prof.
Hiren Patel
 Notes of JAVA
 Textbook of JAVA
 Images from Google Images
 Some my own Knowledge
Thank You :)
public class Thanks
{
public static void main(String args[])
{
System.out.println("Thank You :)");
}
}

More Related Content

What's hot (20)

PPTX
Java Final Keyword
Ducat India
 
PPTX
Union in C programming
Kamal Acharya
 
PPT
Java IO Package and Streams
babak danyal
 
PPSX
Exception Handling
Reddhi Basu
 
PPTX
Java Strings
RaBiya Chaudhry
 
PPTX
Java String
SATYAM SHRIVASTAV
 
PDF
Java data types, variables and jvm
Madishetty Prathibha
 
PPTX
Java Method, Static Block
Infoviaan Technologies
 
PPT
Java: Primitive Data Types
Tareq Hasan
 
PDF
Generics
Ravi_Kant_Sahu
 
PPTX
Access Modifier.pptx
Margaret Mary
 
PDF
Java threads
Prabhakaran V M
 
PDF
Polymorphism In Java
Spotle.ai
 
PPTX
L21 io streams
teach4uin
 
PPTX
Decision making and branching
Saranya saran
 
PPTX
ArrayList in JAVA
SAGARDAVE29
 
PDF
Collections in Java Notes
Shalabh Chaudhary
 
PPTX
java interface and packages
VINOTH R
 
DOCX
Java collections notes
Surendar Meesala
 
PPTX
Dynamic memory allocation in c++
Tech_MX
 
Java Final Keyword
Ducat India
 
Union in C programming
Kamal Acharya
 
Java IO Package and Streams
babak danyal
 
Exception Handling
Reddhi Basu
 
Java Strings
RaBiya Chaudhry
 
Java String
SATYAM SHRIVASTAV
 
Java data types, variables and jvm
Madishetty Prathibha
 
Java Method, Static Block
Infoviaan Technologies
 
Java: Primitive Data Types
Tareq Hasan
 
Generics
Ravi_Kant_Sahu
 
Access Modifier.pptx
Margaret Mary
 
Java threads
Prabhakaran V M
 
Polymorphism In Java
Spotle.ai
 
L21 io streams
teach4uin
 
Decision making and branching
Saranya saran
 
ArrayList in JAVA
SAGARDAVE29
 
Collections in Java Notes
Shalabh Chaudhary
 
java interface and packages
VINOTH R
 
Java collections notes
Surendar Meesala
 
Dynamic memory allocation in c++
Tech_MX
 

Similar to This and Static Keyword (20)

PDF
this keyword in Java.pdf
ParvizMirzayev2
 
PPTX
this keyword in Java.pptx
ParvizMirzayev2
 
PPTX
Java static keyword
Ahmed Shawky El-faky
 
PPTX
Chapter 8 java
Ahmad sohail Kakar
 
PPTX
PPT Lecture-1.4.pptx
HimanshuPandey957216
 
PDF
Principles of Object Oriented Programming
Kasun Ranga Wijeweera
 
PPTX
Packages,static,this keyword in java
Vishnu Suresh
 
PPTX
702641313-CS3391-OBJORIENTEDPS-Unit-2.pptx
SAJITHABANUS
 
PPTX
4- Inheritance, Aggregation, Encapsulation and Overloading
Ghadeer AlHasan
 
PPT
Super and final in java
anshu_atri
 
PDF
Java- language Lecture 6
Hatem Abd El-Salam
 
PPTX
OOP presentation.pptx
AbulHasnatHridoy2211
 
PPTX
UNIT-2.pptx CS3391 Inheritance , types, packages and Interfaces
SakkaravarthiS1
 
PPTX
Dev labs alliance top 20 basic java interview questions for sdet
DevLabs Alliance
 
DOCX
Java sessionnotes
Lakshmi Sarvani Videla
 
PPTX
Hemajava
SangeethaSasi1
 
PPTX
Lecture 6.pptx
AshutoshTrivedi30
 
PPTX
Imp Key.pptx very easy to learn go for it
dwivedyp
 
PPTX
Top 20 basic java interview questions for SDET
DevLabs Alliance
 
PPTX
Dev labs alliance top 20 basic java interview question for sdet
devlabsalliance
 
this keyword in Java.pdf
ParvizMirzayev2
 
this keyword in Java.pptx
ParvizMirzayev2
 
Java static keyword
Ahmed Shawky El-faky
 
Chapter 8 java
Ahmad sohail Kakar
 
PPT Lecture-1.4.pptx
HimanshuPandey957216
 
Principles of Object Oriented Programming
Kasun Ranga Wijeweera
 
Packages,static,this keyword in java
Vishnu Suresh
 
702641313-CS3391-OBJORIENTEDPS-Unit-2.pptx
SAJITHABANUS
 
4- Inheritance, Aggregation, Encapsulation and Overloading
Ghadeer AlHasan
 
Super and final in java
anshu_atri
 
Java- language Lecture 6
Hatem Abd El-Salam
 
OOP presentation.pptx
AbulHasnatHridoy2211
 
UNIT-2.pptx CS3391 Inheritance , types, packages and Interfaces
SakkaravarthiS1
 
Dev labs alliance top 20 basic java interview questions for sdet
DevLabs Alliance
 
Java sessionnotes
Lakshmi Sarvani Videla
 
Hemajava
SangeethaSasi1
 
Lecture 6.pptx
AshutoshTrivedi30
 
Imp Key.pptx very easy to learn go for it
dwivedyp
 
Top 20 basic java interview questions for SDET
DevLabs Alliance
 
Dev labs alliance top 20 basic java interview question for sdet
devlabsalliance
 
Ad

More from Dhrumil Panchal (20)

PPTX
YouTube Cryptocurrency Scam
Dhrumil Panchal
 
PPTX
Servlet and Servlet Life Cycle
Dhrumil Panchal
 
PPTX
Properties and Indexers
Dhrumil Panchal
 
PPTX
Chomsky Normal Form
Dhrumil Panchal
 
PPTX
IEEE 802.11 Architecture and Services
Dhrumil Panchal
 
PPTX
Key roles for successful analytic project in Data Mining
Dhrumil Panchal
 
PPTX
Dynamic Programming Code-Optimization Algorithm (Compiler Design)
Dhrumil Panchal
 
PPTX
Different Software Testing Types and CMM Standard
Dhrumil Panchal
 
PPTX
Web Design Issues
Dhrumil Panchal
 
PPTX
Toy Interpreter
Dhrumil Panchal
 
PPTX
Traditional Problems Associated with Computer Crime
Dhrumil Panchal
 
PPTX
Breadth First Search (BFS)
Dhrumil Panchal
 
PPTX
Timing Diagram of MVI Instruction of 8085 Microprocessor
Dhrumil Panchal
 
PPTX
File Management – File Concept, access methods, File types and File Operation
Dhrumil Panchal
 
PPTX
Constructor and Types of Constructors
Dhrumil Panchal
 
PPTX
Types of Instruction Format
Dhrumil Panchal
 
PPTX
Types of Cables(Guided Media for Transmisson)
Dhrumil Panchal
 
PPTX
Global Service for Mobile Communication
Dhrumil Panchal
 
PPTX
Denial of Service Attack
Dhrumil Panchal
 
PPTX
Fourier Series
Dhrumil Panchal
 
YouTube Cryptocurrency Scam
Dhrumil Panchal
 
Servlet and Servlet Life Cycle
Dhrumil Panchal
 
Properties and Indexers
Dhrumil Panchal
 
Chomsky Normal Form
Dhrumil Panchal
 
IEEE 802.11 Architecture and Services
Dhrumil Panchal
 
Key roles for successful analytic project in Data Mining
Dhrumil Panchal
 
Dynamic Programming Code-Optimization Algorithm (Compiler Design)
Dhrumil Panchal
 
Different Software Testing Types and CMM Standard
Dhrumil Panchal
 
Web Design Issues
Dhrumil Panchal
 
Toy Interpreter
Dhrumil Panchal
 
Traditional Problems Associated with Computer Crime
Dhrumil Panchal
 
Breadth First Search (BFS)
Dhrumil Panchal
 
Timing Diagram of MVI Instruction of 8085 Microprocessor
Dhrumil Panchal
 
File Management – File Concept, access methods, File types and File Operation
Dhrumil Panchal
 
Constructor and Types of Constructors
Dhrumil Panchal
 
Types of Instruction Format
Dhrumil Panchal
 
Types of Cables(Guided Media for Transmisson)
Dhrumil Panchal
 
Global Service for Mobile Communication
Dhrumil Panchal
 
Denial of Service Attack
Dhrumil Panchal
 
Fourier Series
Dhrumil Panchal
 
Ad

Recently uploaded (20)

PDF
Natural Language processing and web deigning notes
AnithaSakthivel3
 
PPTX
Cyclic_Redundancy_Check_Presentation.pptx
alhjranyblalhmwdbdal
 
PPTX
ENSA_Module_8.pptx_nice_ipsec_presentation
RanaMukherjee24
 
PDF
POWER PLANT ENGINEERING (R17A0326).pdf..
haneefachosa123
 
PPTX
Basics of Auto Computer Aided Drafting .pptx
Krunal Thanki
 
PDF
LEARNING CROSS-LINGUAL WORD EMBEDDINGS WITH UNIVERSAL CONCEPTS
kjim477n
 
PDF
A presentation on the Urban Heat Island Effect
studyfor7hrs
 
PDF
Jual GPS Geodetik CHCNAV i93 IMU-RTK Lanjutan dengan Survei Visual
Budi Minds
 
PDF
Non Text Magic Studio Magic Design for Presentations L&P.pdf
rajpal7872
 
PPTX
ENG8 Q1, WEEK 4.pptxoooiioooooooooooooooooooooooooo
chubbychubz1
 
PPTX
File Strucutres and Access in Data Structures
mwaslam2303
 
PDF
IEEE EMBC 2025 「Improving electrolaryngeal speech enhancement via a represent...
NU_I_TODALAB
 
PPTX
Water resources Engineering GIS KRT.pptx
Krunal Thanki
 
PDF
A NEW FAMILY OF OPTICALLY CONTROLLED LOGIC GATES USING NAPHTHOPYRAN MOLECULE
ijoejnl
 
PDF
勉強会資料_An Image is Worth More Than 16x16 Patches
NABLAS株式会社
 
PDF
The Complete Guide to the Role of the Fourth Engineer On Ships
Mahmoud Moghtaderi
 
PDF
PRIZ Academy - Change Flow Thinking Master Change with Confidence.pdf
PRIZ Guru
 
PPTX
Sensor IC System Design Using COMSOL Multiphysics 2025-July.pptx
James D.B. Wang, PhD
 
PPTX
Mining Presentation Underground - Copy.pptx
patallenmoore
 
PDF
13th International Conference of Networks and Communications (NC 2025)
JohannesPaulides
 
Natural Language processing and web deigning notes
AnithaSakthivel3
 
Cyclic_Redundancy_Check_Presentation.pptx
alhjranyblalhmwdbdal
 
ENSA_Module_8.pptx_nice_ipsec_presentation
RanaMukherjee24
 
POWER PLANT ENGINEERING (R17A0326).pdf..
haneefachosa123
 
Basics of Auto Computer Aided Drafting .pptx
Krunal Thanki
 
LEARNING CROSS-LINGUAL WORD EMBEDDINGS WITH UNIVERSAL CONCEPTS
kjim477n
 
A presentation on the Urban Heat Island Effect
studyfor7hrs
 
Jual GPS Geodetik CHCNAV i93 IMU-RTK Lanjutan dengan Survei Visual
Budi Minds
 
Non Text Magic Studio Magic Design for Presentations L&P.pdf
rajpal7872
 
ENG8 Q1, WEEK 4.pptxoooiioooooooooooooooooooooooooo
chubbychubz1
 
File Strucutres and Access in Data Structures
mwaslam2303
 
IEEE EMBC 2025 「Improving electrolaryngeal speech enhancement via a represent...
NU_I_TODALAB
 
Water resources Engineering GIS KRT.pptx
Krunal Thanki
 
A NEW FAMILY OF OPTICALLY CONTROLLED LOGIC GATES USING NAPHTHOPYRAN MOLECULE
ijoejnl
 
勉強会資料_An Image is Worth More Than 16x16 Patches
NABLAS株式会社
 
The Complete Guide to the Role of the Fourth Engineer On Ships
Mahmoud Moghtaderi
 
PRIZ Academy - Change Flow Thinking Master Change with Confidence.pdf
PRIZ Guru
 
Sensor IC System Design Using COMSOL Multiphysics 2025-July.pptx
James D.B. Wang, PhD
 
Mining Presentation Underground - Copy.pptx
patallenmoore
 
13th International Conference of Networks and Communications (NC 2025)
JohannesPaulides
 

This and Static Keyword

  • 1. NAME: DHRUMIL I. PANCHAL SEM: 5TH SEMESTER SUBJECT: OBJECT ORIENTED PROGRAMMING WITH JAVA BRANCH: COMPUTER ENGINEERING (B.E.) YEAR: 2019-20 Welcome
  • 4. This Keyword  There can be a lot of usage of java this keyword. In java, this is a reference variable that refers to the current object.
  • 5. Usage of This Keyword  Here is given the 6 usage of java this keyword. 1. this can be used to refer current class instance variable. 2. this can be used to invoke current class method (implicitly) 3. this() can be used to invoke current class constructor. 4. this can be passed as an argument in the method call. 5. this can be passed as argument in the constructor call. 6. this can be used to return the current class instance from the method.
  • 6. Example // A redundant use of this. Box(double w, double h, double d) { this. width = w; this. height = h; this. depth = d; }
  • 7. Static Keyword  The static keyword in Java is used for memory management mainly. We can apply static keyword with variables, methods, blocks and nested classes. The static keyword belongs to the class than an instance of the class.  The static can be: 1. Variable (also known as a class variable) 2. Method (also known as a class method) 3. Block 4. Nested class
  • 8. Static Variable  If you declare any variable as static, it is known as a static variable.  The static variable can be used to refer to the common property of all objects (which is not unique for each object), for example, the company name of employees, college name of students, etc.  The static variable gets memory only once in the class area at the time of class loading.
  • 9. Static Method  If you apply static keyword with any method, it is known as static method. 1. A static method belongs to the class rather than the object of a class. 2. A static method can be invoked without the need for creating an instance of a class. 3. A static method can access static data member and can change the value of it.
  • 10. Static Block  Is used to initialize the static data member.  It is executed before the main method at the time of class loading.
  • 11. Reference  Inspiration from Prof. Milin Patel and Prof. Hiren Patel  Notes of JAVA  Textbook of JAVA  Images from Google Images  Some my own Knowledge
  • 12. Thank You :) public class Thanks { public static void main(String args[]) { System.out.println("Thank You :)"); } }