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
Wha is the output from system.out.println(“hello”+null); ?
What is the ==?
What is regex java?
What are the actions that can occur when a thread enters blocked state?
Explain the private protected method modifier?
Hi all, I am dng a mini project on FileSplitter application which splits the GBs of logfile into Smaller chunks(mbs) depending on the split size." How to handle GBs file? I am getting OutOfMemoryException, when I input such GB sized file. Thx
How will you add panel to a frame?
Explain hashset and its features?
What is a function in java?
how to create multithreaded program? Explain different ways of using thread? When a thread is created and started, what is its initial state? : Java thread
What is a treeset in java?
When will we prefer to use set and list in java and why?
Define locale.
What is difference between classpath and path variables in java?
Explain differences between checked and unchecked exceptions in java?