What is the final variable and final method ?

No comments


All  methods  and  variable  can  be  overriding  by  default  in  sub-classes  if  we  wish  to  prevent  the  sub-classes  from  overriding  the  member  of  the  super  class  we  can  declare   then,  as  final  using  the  keyword  final  as  modifier.

Example  :-

final  int  size = 20;

final  void  add()

{ ————————-

————————–

}

A   making  a  methods  a  final  answer  that  the  functionality  define  in  any  way.  Similarly  the  value  of  final  variable  can  never  be  change  the  like  class  variable  and  they  do  not  take  any  space  on  individual  object  of  the  class.

No comments :

Post a Comment

Subscribe

Milan Panda
Admin
About Me | Contact
Copyright 2023-2024 © Programming1011 . 🎀 Developed and Design By- Milan Panda. Happy Holi All Of You 🎀