Latest Tutorials| Questions and Answers|Ask Questions?|Site Map




Have Programming Question? Ask it here!
 
 
 


humera
final keyword
2 Answer(s)      3 years and 4 months ago
Posted in : Java Beginners


why is final keyword used in java?


Advertisement
View Answers

April 5, 2011 at 11:25 AM


It is a modifier that indicates that a class cannot be extended, a variable cannot be changed, and a method cannot be overridden.

The final keyword is used in java due to following reasons:

* A java variable that is declared with the keyword final can be assigned only once. They cannot be modified.
* A variable that is declared as final and not initialized is called a blank final variable. A blank final variable forces the constructors to initialize it.
* Java classes declared as final cannot be extended. It cannot be inherited by any other class.
* Methods declared as final cannot be overridden in the sub classes.
* final parameters - values of the parameters cannot be changed after initialization.
* Java local classes can only reference local variables and parameters that are declared as final.
* A visible advantage of declaring a java variable as static final is, the compiled java class results in faster performance.


January 11, 2013 at 3:02 PM


keyword final can be assigned only once. They cannot be modified.



Related Tutorials/Questions & Answers:
final keyword
final keyword  why is final keyword used in java
Final Keyword
Final Keyword  hello, What is final?   hii In case of class if we use final then this class can not be extended or final class may not be subclassed. A final method can't be overridden when its class is inherited
Advertisements
The final Keyword
The final Keyword       The final is a keyword. This is similar to const keyword in other languages. This keyword may not be used as identifiers i.e. you cannot declare
Java: Final keyword
Java NotesFinal keyword The Final word on the final keyword. How often do you use final? Copyleft 2005 Fred Swartz MIT License
Java final Keyword Example
Java final Keyword Example In this section we will read about the final keyword in Java in various context. final keyword in Java can be used with the class name, method name, and variable name. Whichever, the final keyword is used
Java final keyword
Java final keyword The final is a very important keyword in java, which... keyword can be applied to: method class variable Syntax of final class...: The final keyword applied to a class, indicating the class cannot
PHP Final Keyword
Final Keyword in PHP: If you are familiar with Java then you must know the functionality of Final keyword. Final keyword prevents child classes from... of this class. PHP Final Keyword Example: <?php class A { final public
final
final  what does final means in "public static final void main (string args[])" ?   keyword final can be assigned only once. They cannot be modified
Java final
Java final       In the Java programming language, the keyword "final" is used with different entity which makes it unchangeable later. We can have final methods, final
Java final method
final keyword when used with method results in final method, which cannot be overridden in subclass. final keyword is used to restrict user. final keyword... Java final Keyword Example Java final keyword
Java method final parameter
Java method final parameter       Example below demonstrates the working of java final keyword... set to final. This means double type radius is no more a variable
Final Methods - Java Tutorials
The final Keyword in Java In Java, final keyword is applied in various context. The final keyword is a modifier means the final class can't be extended.... final classes The class declared as final can't be subclass or extend
final variable
final variable  Please give some easiest and understanding example program for final variable
final grade
final grade  C. Write a JavaScript program that would input a student?s final grade from 50-100. Evaluate the Final grade and display the Point...?s final grade from 50-100. Evaluate the Final grade and display the Point
What is this keyword?
What is this keyword?  What is this keyword
Keyword - this
Keyword - this       A keyword is a word having a particular meaning to the programming language. Similarly, this keyword is used to represent an object constructed from a class
The if Keyword
The if Keyword         The if is a keyword, which is used to perform the selection... that are executed in case, the test condition specified by the if keyword evaluates
Java keyword
Java keyword  Is sizeof a keyword
super keyword
super keyword  super keyword explain
Final method in java
is declared with final keyword then the variable cannot be changed throughout...Final method in java In this section we will learn about Final method in java. Final  keyword in java is used with class, variable and methods
The for Keyword
The for Keyword       The for is Java keyword that is used to execute a block of code... statement increments the value of i by one. The for keyword may not be used
What is final class?
What is final class?  Hi, What is final class? thanks   Hi, A final class is not be saubclassed. A final method can't be overridden when its class is inherited. You can't change value of a final variable
transient keyword
transient keyword  how to use transient keyword?   Hi Friend, The transient keyword is used to indicate that the member variable should not be serialized when the class instance containing that transient variable
Java Final Variable
Java Final Variable  I have some confusion --Final variable has single copy for each object so can we access final variable through class name,or it is necessary to create object for accessing final variable
Return keyword
Return keyword  how do we use return in methods?   Java use of return keyword import java.util.*; public class ReverseString{ public... at Return Keyword
compute the final grades
compute the final grades  C. Write a JavaScript program that would input a student?s final grade from 50-100. Evaluate the Final grade and display... input a student?s final grade from 50-100. Evaluate the Final grade and display
compute the final grades
compute the final grades  C. Write a JavaScript program that would input a student?s final grade from 50-100. Evaluate the Final grade and display the Point Equivalent based on the table below. Indicate also the remarks
compute the final grades
compute the final grades  C. Write a JavaScript program that would input a student?s final grade from 50-100. Evaluate the Final grade and display the Point Equivalent based on the table below. Indicate also the remarks
compute the final grades
compute the final grades  C. Write a JavaScript program that would input a student?s final grade from 50-100. Evaluate the Final grade and display the Point Equivalent based on the table below. Indicate also the remarks
compute the final grades
compute the final grades  C. Write a JavaScript program that would input a student?s final grade from 50-100. Evaluate the Final grade and display the Point Equivalent based on the table below. Indicate also the remarks
compute the final grades
compute the final grades  C. Write a JavaScript program that would input a student?s final grade from 50-100. Evaluate the Final grade and display the Point Equivalent based on the table below. Indicate also the remarks
private static final
private static final  Why there is necessary to make a variable private static final
servlet as final - JSP-Servlet
servlet as final  whether we can declare final for a servlet or not? and give the reason
Dynamic keyword
Dynamic keyword  hi....... What is the dynamic keyword used for in flex? give me the answer ASAP Thanks  Ans: Dynamic keyword... during the run-time. Just add the magic keyword dynamic to the class definition
static keyword
static keyword  please give some detail about Static keyword.   Static Variables Static variables are class variables that are shared by all instance of class .. 1)It is a variable which belongs to the class
SQL as Keyword
SQL as Keyword       The SQL Key word used in SQL are createTable,Insert into,select,delete... keywords like, create table keyword is used to create a table Stu_Table
Java 5 - "final" is not final anymore - Java Tutorials
Java 5 - "final" is not final anymore   2004-10-07 The Java Specialists' Newsletter [Issue 096] - Java 5 - "final" is not final anymore Author... will start moving to Java 5. Java 5 - "final" is not final anymore
Final Project - Java Beginners
Final Project  The importance of a graphical user interface..., but it is suggested that you begin working on the final project assignment in Week 5, which... the lectures, Quick Test Programs, and Lab assignments will prepare you for the final
static keyword with real example
static keyword with real example  static keyword with real examplestrong text
Can a abstract class be declared final?
Can a abstract class be declared final?   Hi, Can a abstract class be declared final? Thanks
Final Cut Pro X
Final Cut Pro X The Final Cut Pro X is the name of new innovation in the video... during video editing. In fact, today Final Cut Pro X has created... introduces the many formerly missing in action section of its Final Cut Pro site
this java keyword
this java keyword       "this" is a keyword defined in the java programming language. Keywords... in java programming language likewise the this keyword indicates the following
Explain final class, abstract class and super class.
Explain final class, abstract class and super class.  Explain final class, abstract class and super class.   Explain final class, abstract class and super class. A final class cannot be extended. A final class
Can a main method be declared final?
Can a main method be declared final?   Hi, Can a main method be declared final? Thanks   Hi, Yes we can. The final method can be declare as follows: public final String convertCurrency() The final method can't
difference between enum and final class?
difference between enum and final class?  what is the difference between enum and final class in java?   The java.lang.Enum is an abstract... A final class cannot be extended. A final class implicitly has all the methods
private and final - Java Interview Questions
and final modifier in java   Hi Friend, Private modifier indicates... be accessed or instantiated outside. Final modifier indicates.... They cannot be overriden by subclasses. The final class can't be extended
What is the purpose of declaring a variable as final?
What is the purpose of declaring a variable as final?   Hi, What is the purpose of declaring a variable as final? Thanks   Hi, In Java when we declare a final variable as a variable which has been initialized
Final Project II - Java Beginners
Final Project II  Is there anyway I can get the project back by Saturday??? It is due on Sunday by midnight...Thank You
why using static keyword
why using static keyword  why using static keyword
transient keyword - Java Beginners
transient keyword  what is transient keyword in java.? plz explain with example
Advertisements
 

 

 

DMCA.com