Home > DeveloperSection > Interviews > What is final variable in java?

Posted on    March-31-2015 12:46 AM

 Java Java 
 1 Answer(s)
  660  View(s)
Rate this:

Mayank Tripathi
Mayank Tripathi

Total Post:807

Posted on    March-31-2015 1:02 AM

If you make any variable as final, you cannot change the value of final variable(It will be constant).

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(){  
 public static void main(String args[]){  
 Bike9 obj=new  Bike9();  
}//end of class  

Output:Compile Time Error

Don't want to miss updates? Please click the below button!

Follow MindStick