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



Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


humera
final keyword
2 Answer(s)      3 years and 7 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 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
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
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
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
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
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
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
 

 

 

DMCA.com