SlideShare a Scribd company logo
Final Keyword In Java
• The final keyword in java is used to restrict
the user. The java final keyword can be used in
many context. Final can be:
• variable
• method
• class
• The final keyword can be applied with the
variables, a final variable that have no value it
is called blank final variable or uninitialized
final variable. It can be initialized in the
constructor only. The blank final variable can
be static also which will be initialized in the
static block only.
• Let's first learn the basics of final keyword.
Java final variable
• If you make any variable as final, you cannot
change the value of final variable(It will be
constant).
Example of final variable
• There is a final variable speedlimit, we are
going to change the value of this variable, but
It can't be changed because final variable once
assigned a value can never be changed.
• class Bike9{
• final int speedlimit=90;//final variable
• void run(){
• speedlimit=400;
• }
• public static void main(String args[]){
• Bike9 obj=new Bike9();
• obj.run();
• }
• }//end of class
Java final method
• If you make any method as final, you cannot
override it.
class Bike{
final void run(){System.out.println("running");
} }
class Honda extends Bike{
void run(){System.out.println("running safely wi
th 100kmph");}
public static void main(String args[]){
Honda honda= new Honda();
honda.run();
} }
Java final class
• If you make any class as final, you cannot
extend it.
final class Bike{}
class Honda1 extends Bike
{
void run()
{System.out.println("running safely with 100kmph")
;
}
public static void main(String args[]){
Honda1 honda= new Honda();
honda.run();
}
}
Is final method inherited?
• Yes, final method is inherited but you cannot
override it.
• class Bike
• {
• final void run(){System.out.println("running..
.");}
• }
• class Honda2 extends Bike{
• public static void main(String args[]){
• new Honda2().run();
• }
• }
What is blank or uninitialized final
variable?
• A final variable that is not initialized at the
time of declaration is known as blank final
variable.
• If you want to create a variable that is
initialized at the time of creating object and
once initialized may not be changed, it is
useful. For example PAN CARD number of an
employee.
• It can be initialized only in constructor.
Can we initialize blank final variable?
• Yes, but only in constructor.
• class Bike10{
• final int speedlimit;//blank final variable
•
• Bike10(){
• speedlimit=70;
• System.out.println(speedlimit);
• }
•
• public static void main(String args[]){
• new Bike10();
• }
• }
static blank final variable
• A static final variable that is not initialized at
the time of declaration is known as static
blank final variable. It can be initialized only in
static block.
class A
{
static final int data;//static blank final variable
static
{
data=50;
}
public static void main(String args[]){
System.out.println(A.data);
}
}
What is final parameter?
• If you declare any parameter as final, you
cannot change the value of it.
• class Bike11{
• int cube(final int n)
• {
• n=n+2;//can't be changed as n is final
• n*n*n;
• }
• public static void main(String args[]){
• Bike11 b=new Bike11();
• b.cube(5);
• } }
Can we declare a constructor final?
• No, because constructor is never inherited.
Ad

More Related Content

Similar to finalkeywordinjava abstract,interface,implementation.-170702034453.ppt (20)

#_ varible function
#_ varible function #_ varible function
#_ varible function
abdullah al mahamud rosi
 
Intro to JavaScript - Week 2: Function
Intro to JavaScript - Week 2: FunctionIntro to JavaScript - Week 2: Function
Intro to JavaScript - Week 2: Function
Jeongbae Oh
 
Chapter 2 java
Chapter 2 javaChapter 2 java
Chapter 2 java
Ahmad sohail Kakar
 
11.C++Polymorphism [Autosaved].pptx
11.C++Polymorphism [Autosaved].pptx11.C++Polymorphism [Autosaved].pptx
11.C++Polymorphism [Autosaved].pptx
AtharvPotdar2
 
The maze of Design Patterns & SOLID Principles
The maze of Design Patterns & SOLID PrinciplesThe maze of Design Patterns & SOLID Principles
The maze of Design Patterns & SOLID Principles
Muhammad Raza
 
Static Data Members and Member Functions
Static Data Members and Member FunctionsStatic Data Members and Member Functions
Static Data Members and Member Functions
MOHIT AGARWAL
 
Session 45 - Spring - Part 3 - AOP
Session 45 - Spring - Part 3 - AOPSession 45 - Spring - Part 3 - AOP
Session 45 - Spring - Part 3 - AOP
PawanMM
 
01-class-and-objects java code in the .pdf
01-class-and-objects  java code  in the .pdf01-class-and-objects  java code  in the .pdf
01-class-and-objects java code in the .pdf
sithumMarasighe
 
Introduction to c first week slides
Introduction to c first week slidesIntroduction to c first week slides
Introduction to c first week slides
luqman bawany
 
Week 7 Java Programming Methods For I.T students.pdf
Week 7 Java Programming Methods For I.T students.pdfWeek 7 Java Programming Methods For I.T students.pdf
Week 7 Java Programming Methods For I.T students.pdf
JaypeeGPolancos
 
STL Algorithms In Action
STL Algorithms In ActionSTL Algorithms In Action
STL Algorithms In Action
Northwest C++ Users' Group
 
Java For beginners and CSIT and IT students
Java  For beginners and CSIT and IT studentsJava  For beginners and CSIT and IT students
Java For beginners and CSIT and IT students
Partnered Health
 
object oriented programming language.pptx
object oriented programming language.pptxobject oriented programming language.pptx
object oriented programming language.pptx
syedabbas594247
 
java.pptx
java.pptxjava.pptx
java.pptx
PRASHANTKULKARNI133
 
Complete PPT about the Java lokesh kept it
Complete PPT about the Java lokesh kept itComplete PPT about the Java lokesh kept it
Complete PPT about the Java lokesh kept it
lokeshpappaka10
 
2CPP18 - Modifiers
2CPP18 - Modifiers2CPP18 - Modifiers
2CPP18 - Modifiers
Michael Heron
 
Inside the JVM - Follow the white rabbit!
Inside the JVM - Follow the white rabbit!Inside the JVM - Follow the white rabbit!
Inside the JVM - Follow the white rabbit!
Sylvain Wallez
 
18.Static Data Members and Static member function.pptx
18.Static Data Members and Static member function.pptx18.Static Data Members and Static member function.pptx
18.Static Data Members and Static member function.pptx
sanketkashyap2023
 
Java non access modifiers
Java non access modifiersJava non access modifiers
Java non access modifiers
Srinivas Reddy
 
Spring - Part 3 - AOP
Spring - Part 3 - AOPSpring - Part 3 - AOP
Spring - Part 3 - AOP
Hitesh-Java
 
Intro to JavaScript - Week 2: Function
Intro to JavaScript - Week 2: FunctionIntro to JavaScript - Week 2: Function
Intro to JavaScript - Week 2: Function
Jeongbae Oh
 
11.C++Polymorphism [Autosaved].pptx
11.C++Polymorphism [Autosaved].pptx11.C++Polymorphism [Autosaved].pptx
11.C++Polymorphism [Autosaved].pptx
AtharvPotdar2
 
The maze of Design Patterns & SOLID Principles
The maze of Design Patterns & SOLID PrinciplesThe maze of Design Patterns & SOLID Principles
The maze of Design Patterns & SOLID Principles
Muhammad Raza
 
Static Data Members and Member Functions
Static Data Members and Member FunctionsStatic Data Members and Member Functions
Static Data Members and Member Functions
MOHIT AGARWAL
 
Session 45 - Spring - Part 3 - AOP
Session 45 - Spring - Part 3 - AOPSession 45 - Spring - Part 3 - AOP
Session 45 - Spring - Part 3 - AOP
PawanMM
 
01-class-and-objects java code in the .pdf
01-class-and-objects  java code  in the .pdf01-class-and-objects  java code  in the .pdf
01-class-and-objects java code in the .pdf
sithumMarasighe
 
Introduction to c first week slides
Introduction to c first week slidesIntroduction to c first week slides
Introduction to c first week slides
luqman bawany
 
Week 7 Java Programming Methods For I.T students.pdf
Week 7 Java Programming Methods For I.T students.pdfWeek 7 Java Programming Methods For I.T students.pdf
Week 7 Java Programming Methods For I.T students.pdf
JaypeeGPolancos
 
Java For beginners and CSIT and IT students
Java  For beginners and CSIT and IT studentsJava  For beginners and CSIT and IT students
Java For beginners and CSIT and IT students
Partnered Health
 
object oriented programming language.pptx
object oriented programming language.pptxobject oriented programming language.pptx
object oriented programming language.pptx
syedabbas594247
 
Complete PPT about the Java lokesh kept it
Complete PPT about the Java lokesh kept itComplete PPT about the Java lokesh kept it
Complete PPT about the Java lokesh kept it
lokeshpappaka10
 
Inside the JVM - Follow the white rabbit!
Inside the JVM - Follow the white rabbit!Inside the JVM - Follow the white rabbit!
Inside the JVM - Follow the white rabbit!
Sylvain Wallez
 
18.Static Data Members and Static member function.pptx
18.Static Data Members and Static member function.pptx18.Static Data Members and Static member function.pptx
18.Static Data Members and Static member function.pptx
sanketkashyap2023
 
Java non access modifiers
Java non access modifiersJava non access modifiers
Java non access modifiers
Srinivas Reddy
 
Spring - Part 3 - AOP
Spring - Part 3 - AOPSpring - Part 3 - AOP
Spring - Part 3 - AOP
Hitesh-Java
 

More from ArunPatrick2 (20)

Introduction to HTML table,width,height.ppt
Introduction to HTML table,width,height.pptIntroduction to HTML table,width,height.ppt
Introduction to HTML table,width,height.ppt
ArunPatrick2
 
introduction to java Multithreading presentation.pptx
introduction to  java Multithreading presentation.pptxintroduction to  java Multithreading presentation.pptx
introduction to java Multithreading presentation.pptx
ArunPatrick2
 
topic-6-Presentation e-commerce,B2B,B2C,C2C.ppt
topic-6-Presentation e-commerce,B2B,B2C,C2C.ppttopic-6-Presentation e-commerce,B2B,B2C,C2C.ppt
topic-6-Presentation e-commerce,B2B,B2C,C2C.ppt
ArunPatrick2
 
collectionsframework210616084411 (1).pptx
collectionsframework210616084411 (1).pptxcollectionsframework210616084411 (1).pptx
collectionsframework210616084411 (1).pptx
ArunPatrick2
 
Interfaces implements,presentation in java.ppt
Interfaces implements,presentation in java.pptInterfaces implements,presentation in java.ppt
Interfaces implements,presentation in java.ppt
ArunPatrick2
 
multithreading,thread and processinjava-210302183809.pptx
multithreading,thread and processinjava-210302183809.pptxmultithreading,thread and processinjava-210302183809.pptx
multithreading,thread and processinjava-210302183809.pptx
ArunPatrick2
 
InterfaceAbstractClass presentation.pptx
InterfaceAbstractClass presentation.pptxInterfaceAbstractClass presentation.pptx
InterfaceAbstractClass presentation.pptx
ArunPatrick2
 
unit3 Exception Handling multithreadingppt.pptx
unit3 Exception Handling multithreadingppt.pptxunit3 Exception Handling multithreadingppt.pptx
unit3 Exception Handling multithreadingppt.pptx
ArunPatrick2
 
presentation-on-exception-handling-160611180456 (1).pptx
presentation-on-exception-handling-160611180456 (1).pptxpresentation-on-exception-handling-160611180456 (1).pptx
presentation-on-exception-handling-160611180456 (1).pptx
ArunPatrick2
 
unit3multithreadingppt-copy-180122162204.pptx
unit3multithreadingppt-copy-180122162204.pptxunit3multithreadingppt-copy-180122162204.pptx
unit3multithreadingppt-copy-180122162204.pptx
ArunPatrick2
 
java package java package in java packages
java package java package in java packagesjava package java package in java packages
java package java package in java packages
ArunPatrick2
 
Interfaces in java.. introduction, classes, objects
Interfaces in java.. introduction, classes, objectsInterfaces in java.. introduction, classes, objects
Interfaces in java.. introduction, classes, objects
ArunPatrick2
 
javapackage,try,cthrow,finallytch,-160518085421 (1).pptx
javapackage,try,cthrow,finallytch,-160518085421 (1).pptxjavapackage,try,cthrow,finallytch,-160518085421 (1).pptx
javapackage,try,cthrow,finallytch,-160518085421 (1).pptx
ArunPatrick2
 
Exception Handling,finally,catch,throw,throws,try.pptx
Exception Handling,finally,catch,throw,throws,try.pptxException Handling,finally,catch,throw,throws,try.pptx
Exception Handling,finally,catch,throw,throws,try.pptx
ArunPatrick2
 
Inheritance,single,multiple.access rulepptx
Inheritance,single,multiple.access rulepptxInheritance,single,multiple.access rulepptx
Inheritance,single,multiple.access rulepptx
ArunPatrick2
 
Data Analytics overview,kDD process,mining Techniques.pptx
Data Analytics overview,kDD process,mining Techniques.pptxData Analytics overview,kDD process,mining Techniques.pptx
Data Analytics overview,kDD process,mining Techniques.pptx
ArunPatrick2
 
Data warehouse-complete-1-100227093028-phpapp01.pptx
Data warehouse-complete-1-100227093028-phpapp01.pptxData warehouse-complete-1-100227093028-phpapp01.pptx
Data warehouse-complete-1-100227093028-phpapp01.pptx
ArunPatrick2
 
DataWarehouse Architecture,daat mining,data mart,etl process.pptx
DataWarehouse Architecture,daat mining,data mart,etl process.pptxDataWarehouse Architecture,daat mining,data mart,etl process.pptx
DataWarehouse Architecture,daat mining,data mart,etl process.pptx
ArunPatrick2
 
Difference between Abstract class and Interface.pptx
Difference between Abstract class and Interface.pptxDifference between Abstract class and Interface.pptx
Difference between Abstract class and Interface.pptx
ArunPatrick2
 
InterfaceAbstractClass,interfaces,final keyword,.pptx
InterfaceAbstractClass,interfaces,final keyword,.pptxInterfaceAbstractClass,interfaces,final keyword,.pptx
InterfaceAbstractClass,interfaces,final keyword,.pptx
ArunPatrick2
 
Introduction to HTML table,width,height.ppt
Introduction to HTML table,width,height.pptIntroduction to HTML table,width,height.ppt
Introduction to HTML table,width,height.ppt
ArunPatrick2
 
introduction to java Multithreading presentation.pptx
introduction to  java Multithreading presentation.pptxintroduction to  java Multithreading presentation.pptx
introduction to java Multithreading presentation.pptx
ArunPatrick2
 
topic-6-Presentation e-commerce,B2B,B2C,C2C.ppt
topic-6-Presentation e-commerce,B2B,B2C,C2C.ppttopic-6-Presentation e-commerce,B2B,B2C,C2C.ppt
topic-6-Presentation e-commerce,B2B,B2C,C2C.ppt
ArunPatrick2
 
collectionsframework210616084411 (1).pptx
collectionsframework210616084411 (1).pptxcollectionsframework210616084411 (1).pptx
collectionsframework210616084411 (1).pptx
ArunPatrick2
 
Interfaces implements,presentation in java.ppt
Interfaces implements,presentation in java.pptInterfaces implements,presentation in java.ppt
Interfaces implements,presentation in java.ppt
ArunPatrick2
 
multithreading,thread and processinjava-210302183809.pptx
multithreading,thread and processinjava-210302183809.pptxmultithreading,thread and processinjava-210302183809.pptx
multithreading,thread and processinjava-210302183809.pptx
ArunPatrick2
 
InterfaceAbstractClass presentation.pptx
InterfaceAbstractClass presentation.pptxInterfaceAbstractClass presentation.pptx
InterfaceAbstractClass presentation.pptx
ArunPatrick2
 
unit3 Exception Handling multithreadingppt.pptx
unit3 Exception Handling multithreadingppt.pptxunit3 Exception Handling multithreadingppt.pptx
unit3 Exception Handling multithreadingppt.pptx
ArunPatrick2
 
presentation-on-exception-handling-160611180456 (1).pptx
presentation-on-exception-handling-160611180456 (1).pptxpresentation-on-exception-handling-160611180456 (1).pptx
presentation-on-exception-handling-160611180456 (1).pptx
ArunPatrick2
 
unit3multithreadingppt-copy-180122162204.pptx
unit3multithreadingppt-copy-180122162204.pptxunit3multithreadingppt-copy-180122162204.pptx
unit3multithreadingppt-copy-180122162204.pptx
ArunPatrick2
 
java package java package in java packages
java package java package in java packagesjava package java package in java packages
java package java package in java packages
ArunPatrick2
 
Interfaces in java.. introduction, classes, objects
Interfaces in java.. introduction, classes, objectsInterfaces in java.. introduction, classes, objects
Interfaces in java.. introduction, classes, objects
ArunPatrick2
 
javapackage,try,cthrow,finallytch,-160518085421 (1).pptx
javapackage,try,cthrow,finallytch,-160518085421 (1).pptxjavapackage,try,cthrow,finallytch,-160518085421 (1).pptx
javapackage,try,cthrow,finallytch,-160518085421 (1).pptx
ArunPatrick2
 
Exception Handling,finally,catch,throw,throws,try.pptx
Exception Handling,finally,catch,throw,throws,try.pptxException Handling,finally,catch,throw,throws,try.pptx
Exception Handling,finally,catch,throw,throws,try.pptx
ArunPatrick2
 
Inheritance,single,multiple.access rulepptx
Inheritance,single,multiple.access rulepptxInheritance,single,multiple.access rulepptx
Inheritance,single,multiple.access rulepptx
ArunPatrick2
 
Data Analytics overview,kDD process,mining Techniques.pptx
Data Analytics overview,kDD process,mining Techniques.pptxData Analytics overview,kDD process,mining Techniques.pptx
Data Analytics overview,kDD process,mining Techniques.pptx
ArunPatrick2
 
Data warehouse-complete-1-100227093028-phpapp01.pptx
Data warehouse-complete-1-100227093028-phpapp01.pptxData warehouse-complete-1-100227093028-phpapp01.pptx
Data warehouse-complete-1-100227093028-phpapp01.pptx
ArunPatrick2
 
DataWarehouse Architecture,daat mining,data mart,etl process.pptx
DataWarehouse Architecture,daat mining,data mart,etl process.pptxDataWarehouse Architecture,daat mining,data mart,etl process.pptx
DataWarehouse Architecture,daat mining,data mart,etl process.pptx
ArunPatrick2
 
Difference between Abstract class and Interface.pptx
Difference between Abstract class and Interface.pptxDifference between Abstract class and Interface.pptx
Difference between Abstract class and Interface.pptx
ArunPatrick2
 
InterfaceAbstractClass,interfaces,final keyword,.pptx
InterfaceAbstractClass,interfaces,final keyword,.pptxInterfaceAbstractClass,interfaces,final keyword,.pptx
InterfaceAbstractClass,interfaces,final keyword,.pptx
ArunPatrick2
 
Ad

Recently uploaded (20)

History Of The Monastery Of Mor Gabriel Philoxenos Yuhanon Dolabani
History Of The Monastery Of Mor Gabriel Philoxenos Yuhanon DolabaniHistory Of The Monastery Of Mor Gabriel Philoxenos Yuhanon Dolabani
History Of The Monastery Of Mor Gabriel Philoxenos Yuhanon Dolabani
fruinkamel7m
 
All About the 990 Unlocking Its Mysteries and Its Power.pdf
All About the 990 Unlocking Its Mysteries and Its Power.pdfAll About the 990 Unlocking Its Mysteries and Its Power.pdf
All About the 990 Unlocking Its Mysteries and Its Power.pdf
TechSoup
 
How to Manage Amounts in Local Currency in Odoo 18 Purchase
How to Manage Amounts in Local Currency in Odoo 18 PurchaseHow to Manage Amounts in Local Currency in Odoo 18 Purchase
How to Manage Amounts in Local Currency in Odoo 18 Purchase
Celine George
 
Botany Assignment Help Guide - Academic Excellence
Botany Assignment Help Guide - Academic ExcellenceBotany Assignment Help Guide - Academic Excellence
Botany Assignment Help Guide - Academic Excellence
online college homework help
 
antiquity of writing in ancient India- literary & archaeological evidence
antiquity of writing in ancient India- literary & archaeological evidenceantiquity of writing in ancient India- literary & archaeological evidence
antiquity of writing in ancient India- literary & archaeological evidence
PrachiSontakke5
 
Drugs in Anaesthesia and Intensive Care,.pdf
Drugs in Anaesthesia and Intensive Care,.pdfDrugs in Anaesthesia and Intensive Care,.pdf
Drugs in Anaesthesia and Intensive Care,.pdf
crewot855
 
Myasthenia gravis (Neuromuscular disorder)
Myasthenia gravis (Neuromuscular disorder)Myasthenia gravis (Neuromuscular disorder)
Myasthenia gravis (Neuromuscular disorder)
Mohamed Rizk Khodair
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...
BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...
BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...
Nguyen Thanh Tu Collection
 
LDMMIA Reiki Yoga S5 Daily Living Workshop
LDMMIA Reiki Yoga S5 Daily Living WorkshopLDMMIA Reiki Yoga S5 Daily Living Workshop
LDMMIA Reiki Yoga S5 Daily Living Workshop
LDM Mia eStudios
 
The History of Kashmir Karkota Dynasty NEP.pptx
The History of Kashmir Karkota Dynasty NEP.pptxThe History of Kashmir Karkota Dynasty NEP.pptx
The History of Kashmir Karkota Dynasty NEP.pptx
Arya Mahila P. G. College, Banaras Hindu University, Varanasi, India.
 
*"Sensing the World: Insect Sensory Systems"*
*"Sensing the World: Insect Sensory Systems"**"Sensing the World: Insect Sensory Systems"*
*"Sensing the World: Insect Sensory Systems"*
Arshad Shaikh
 
LDMMIA Reiki News Ed3 Vol1 For Team and Guests
LDMMIA Reiki News Ed3 Vol1 For Team and GuestsLDMMIA Reiki News Ed3 Vol1 For Team and Guests
LDMMIA Reiki News Ed3 Vol1 For Team and Guests
LDM Mia eStudios
 
How To Maximize Sales Performance using Odoo 18 Diverse views in sales module
How To Maximize Sales Performance using Odoo 18 Diverse views in sales moduleHow To Maximize Sales Performance using Odoo 18 Diverse views in sales module
How To Maximize Sales Performance using Odoo 18 Diverse views in sales module
Celine George
 
Myopathies (muscle disorders) for undergraduate
Myopathies (muscle disorders) for undergraduateMyopathies (muscle disorders) for undergraduate
Myopathies (muscle disorders) for undergraduate
Mohamed Rizk Khodair
 
Rock Art As a Source of Ancient Indian History
Rock Art As a Source of Ancient Indian HistoryRock Art As a Source of Ancient Indian History
Rock Art As a Source of Ancient Indian History
Virag Sontakke
 
ANTI-VIRAL DRUGS unit 3 Pharmacology 3.pptx
ANTI-VIRAL DRUGS unit 3 Pharmacology 3.pptxANTI-VIRAL DRUGS unit 3 Pharmacology 3.pptx
ANTI-VIRAL DRUGS unit 3 Pharmacology 3.pptx
Mayuri Chavan
 
Form View Attributes in Odoo 18 - Odoo Slides
Form View Attributes in Odoo 18 - Odoo SlidesForm View Attributes in Odoo 18 - Odoo Slides
Form View Attributes in Odoo 18 - Odoo Slides
Celine George
 
How to Share Accounts Between Companies in Odoo 18
How to Share Accounts Between Companies in Odoo 18How to Share Accounts Between Companies in Odoo 18
How to Share Accounts Between Companies in Odoo 18
Celine George
 
Cultivation Practice of Turmeric in Nepal.pptx
Cultivation Practice of Turmeric in Nepal.pptxCultivation Practice of Turmeric in Nepal.pptx
Cultivation Practice of Turmeric in Nepal.pptx
UmeshTimilsina1
 
Cultivation Practice of Garlic in Nepal.pptx
Cultivation Practice of Garlic in Nepal.pptxCultivation Practice of Garlic in Nepal.pptx
Cultivation Practice of Garlic in Nepal.pptx
UmeshTimilsina1
 
History Of The Monastery Of Mor Gabriel Philoxenos Yuhanon Dolabani
History Of The Monastery Of Mor Gabriel Philoxenos Yuhanon DolabaniHistory Of The Monastery Of Mor Gabriel Philoxenos Yuhanon Dolabani
History Of The Monastery Of Mor Gabriel Philoxenos Yuhanon Dolabani
fruinkamel7m
 
All About the 990 Unlocking Its Mysteries and Its Power.pdf
All About the 990 Unlocking Its Mysteries and Its Power.pdfAll About the 990 Unlocking Its Mysteries and Its Power.pdf
All About the 990 Unlocking Its Mysteries and Its Power.pdf
TechSoup
 
How to Manage Amounts in Local Currency in Odoo 18 Purchase
How to Manage Amounts in Local Currency in Odoo 18 PurchaseHow to Manage Amounts in Local Currency in Odoo 18 Purchase
How to Manage Amounts in Local Currency in Odoo 18 Purchase
Celine George
 
Botany Assignment Help Guide - Academic Excellence
Botany Assignment Help Guide - Academic ExcellenceBotany Assignment Help Guide - Academic Excellence
Botany Assignment Help Guide - Academic Excellence
online college homework help
 
antiquity of writing in ancient India- literary & archaeological evidence
antiquity of writing in ancient India- literary & archaeological evidenceantiquity of writing in ancient India- literary & archaeological evidence
antiquity of writing in ancient India- literary & archaeological evidence
PrachiSontakke5
 
Drugs in Anaesthesia and Intensive Care,.pdf
Drugs in Anaesthesia and Intensive Care,.pdfDrugs in Anaesthesia and Intensive Care,.pdf
Drugs in Anaesthesia and Intensive Care,.pdf
crewot855
 
Myasthenia gravis (Neuromuscular disorder)
Myasthenia gravis (Neuromuscular disorder)Myasthenia gravis (Neuromuscular disorder)
Myasthenia gravis (Neuromuscular disorder)
Mohamed Rizk Khodair
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...
BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...
BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...
Nguyen Thanh Tu Collection
 
LDMMIA Reiki Yoga S5 Daily Living Workshop
LDMMIA Reiki Yoga S5 Daily Living WorkshopLDMMIA Reiki Yoga S5 Daily Living Workshop
LDMMIA Reiki Yoga S5 Daily Living Workshop
LDM Mia eStudios
 
*"Sensing the World: Insect Sensory Systems"*
*"Sensing the World: Insect Sensory Systems"**"Sensing the World: Insect Sensory Systems"*
*"Sensing the World: Insect Sensory Systems"*
Arshad Shaikh
 
LDMMIA Reiki News Ed3 Vol1 For Team and Guests
LDMMIA Reiki News Ed3 Vol1 For Team and GuestsLDMMIA Reiki News Ed3 Vol1 For Team and Guests
LDMMIA Reiki News Ed3 Vol1 For Team and Guests
LDM Mia eStudios
 
How To Maximize Sales Performance using Odoo 18 Diverse views in sales module
How To Maximize Sales Performance using Odoo 18 Diverse views in sales moduleHow To Maximize Sales Performance using Odoo 18 Diverse views in sales module
How To Maximize Sales Performance using Odoo 18 Diverse views in sales module
Celine George
 
Myopathies (muscle disorders) for undergraduate
Myopathies (muscle disorders) for undergraduateMyopathies (muscle disorders) for undergraduate
Myopathies (muscle disorders) for undergraduate
Mohamed Rizk Khodair
 
Rock Art As a Source of Ancient Indian History
Rock Art As a Source of Ancient Indian HistoryRock Art As a Source of Ancient Indian History
Rock Art As a Source of Ancient Indian History
Virag Sontakke
 
ANTI-VIRAL DRUGS unit 3 Pharmacology 3.pptx
ANTI-VIRAL DRUGS unit 3 Pharmacology 3.pptxANTI-VIRAL DRUGS unit 3 Pharmacology 3.pptx
ANTI-VIRAL DRUGS unit 3 Pharmacology 3.pptx
Mayuri Chavan
 
Form View Attributes in Odoo 18 - Odoo Slides
Form View Attributes in Odoo 18 - Odoo SlidesForm View Attributes in Odoo 18 - Odoo Slides
Form View Attributes in Odoo 18 - Odoo Slides
Celine George
 
How to Share Accounts Between Companies in Odoo 18
How to Share Accounts Between Companies in Odoo 18How to Share Accounts Between Companies in Odoo 18
How to Share Accounts Between Companies in Odoo 18
Celine George
 
Cultivation Practice of Turmeric in Nepal.pptx
Cultivation Practice of Turmeric in Nepal.pptxCultivation Practice of Turmeric in Nepal.pptx
Cultivation Practice of Turmeric in Nepal.pptx
UmeshTimilsina1
 
Cultivation Practice of Garlic in Nepal.pptx
Cultivation Practice of Garlic in Nepal.pptxCultivation Practice of Garlic in Nepal.pptx
Cultivation Practice of Garlic in Nepal.pptx
UmeshTimilsina1
 
Ad

finalkeywordinjava abstract,interface,implementation.-170702034453.ppt

  • 2. • The final keyword in java is used to restrict the user. The java final keyword can be used in many context. Final can be: • variable • method • class
  • 3. • The final keyword can be applied with the variables, a final variable that have no value it is called blank final variable or uninitialized final variable. It can be initialized in the constructor only. The blank final variable can be static also which will be initialized in the static block only. • Let's first learn the basics of final keyword.
  • 4. Java final variable • If you make any variable as final, you cannot change the value of final variable(It will be constant).
  • 5. Example of final variable • There is a final variable speedlimit, we are going to change the value of this variable, but It can't be changed because final variable once assigned a value can never be changed.
  • 6. • class Bike9{ • final int speedlimit=90;//final variable • void run(){ • speedlimit=400; • } • public static void main(String args[]){ • Bike9 obj=new Bike9(); • obj.run(); • } • }//end of class
  • 7. Java final method • If you make any method as final, you cannot override it.
  • 8. class Bike{ final void run(){System.out.println("running"); } } class Honda extends Bike{ void run(){System.out.println("running safely wi th 100kmph");} public static void main(String args[]){ Honda honda= new Honda(); honda.run(); } }
  • 9. Java final class • If you make any class as final, you cannot extend it.
  • 10. final class Bike{} class Honda1 extends Bike { void run() {System.out.println("running safely with 100kmph") ; } public static void main(String args[]){ Honda1 honda= new Honda(); honda.run(); } }
  • 11. Is final method inherited? • Yes, final method is inherited but you cannot override it.
  • 12. • class Bike • { • final void run(){System.out.println("running.. .");} • } • class Honda2 extends Bike{ • public static void main(String args[]){ • new Honda2().run(); • } • }
  • 13. What is blank or uninitialized final variable? • A final variable that is not initialized at the time of declaration is known as blank final variable. • If you want to create a variable that is initialized at the time of creating object and once initialized may not be changed, it is useful. For example PAN CARD number of an employee. • It can be initialized only in constructor.
  • 14. Can we initialize blank final variable? • Yes, but only in constructor.
  • 15. • class Bike10{ • final int speedlimit;//blank final variable • • Bike10(){ • speedlimit=70; • System.out.println(speedlimit); • } • • public static void main(String args[]){ • new Bike10(); • } • }
  • 16. static blank final variable • A static final variable that is not initialized at the time of declaration is known as static blank final variable. It can be initialized only in static block.
  • 17. class A { static final int data;//static blank final variable static { data=50; } public static void main(String args[]){ System.out.println(A.data); } }
  • 18. What is final parameter? • If you declare any parameter as final, you cannot change the value of it.
  • 19. • class Bike11{ • int cube(final int n) • { • n=n+2;//can't be changed as n is final • n*n*n; • } • public static void main(String args[]){ • Bike11 b=new Bike11(); • b.cube(5); • } }
  • 20. Can we declare a constructor final? • No, because constructor is never inherited.
  翻译: