AIM: Write a program in Java to demonstrate the use of 'final' keyword in the field declaration. How it is accessed using the objects.
FinalKeyword.java
Output
Happy Coding :)
FinalKeyword.java
class FinalKeyword { final int collageCode=621; void display() { System.out.println("Collage Code is "+collageCode); // this reassignment of final variable generates error collageCode=622; // comment this line for see proper output } public static void main(String arg[]) { FinalKeyword f=new FinalKeyword(); f.display(); } }
Output
Final Keyword in java by practical server |
Happy Coding :)
0 Comments
Post a Comment