Question

In Java, it is valid to apply the "final" keyword at three levels: to a variable,...

In Java, it is valid to apply the "final" keyword at three levels: to a variable, to a method within a class and to a class itself. Describe the distinct effect of the final keyword at each of these levels: variable, method, class levels.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

We use the final keyword in the entity declaration. This entity can be a variable, method or class. It specifies that the value cant be modified in the future

The final keyword before variable:

Specifying the final keyword before a variable means that the value of the variable once initialized cant be modified in the future.

The final keyword before method:

Methods of the class having final keywords cannot be overridden or hidden by its subclasses.

Similarly,

the final keyword before class name specifies that the particular class cannot be subclassed.

I hope it helps

Please get back to me in comment section, in case of any query

Add a comment
Know the answer?
Add Answer to:
In Java, it is valid to apply the "final" keyword at three levels: to a variable,...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT