Follow Our FB Page << CircleMedia.in >> for Daily Laughter. We Post Funny, Viral, Comedy Videos, Memes, Vines...

what is finalmethod & final variable with example?

Answer Posted / pavan

final method or variable is nothing but once if we declare
as it is final the value of that variable cant be changed
and becomes const.
Example:
--------
final b=200;
Here the value of b is 200 thought the prog
class A
{
void final b=200;
}//A
class B extends class A
{
this.b=201;//Error becoz the variable b is declared as final
//Here this represents the current value i.e.,in
class B that is about variable final

Know coming to the method:
-------------------------
final Add();//similar as variable
Final method can be def as the method name can not be
re-used and at the same time it cant be overridden..
Example:
--------
class A{
final Add()
{
int a,b,c;//Here in this we are adding two int no.
c=a+b;
}
class B extends class A
{
final Add()
{
float a,b,c;//Here we are adding two float no.
c=a+b;
}

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What do you mean by JVM?

243


What are recursive functions? Give some examples?

261


Does java arraylist maintain insertion order?

207


Name few java 8 annotations ?

238


What are the difference between string, string builder, and string buffer in java?

225






Can we force the garbage collection to run?

249


Hi i am creating desktop application in that i want calling to mobile number. i have java telephone api (JTAPI) but i dont understand how it configure & use plese help me

1078


List some java keywords sun like c, c + + keywords?

229


Explain an intermediate language?

208


What is the use of static methods?

221


What are loops in java?

226


How large is a boolean?

216


What is Enum in Java?

302


What is a constructor overloading in java?

212


Can we extend a class with private constructor?

193