Final Methods

Final Methods

In a final method we use final keyword, its prevents method from being overridden in a subclass, And its used to enforce for API functionality of a method. We have a example the Thread class have a method which is called isAlive() that checks whether a thread is still active.if we would like to extend the thread class , and also we can correctly implement this method themselves.

A typical final method declaration looks like this
class SuperClass{
public final void showSample() {
System.out.println(\"One thing.\");

Date:2024-02-09 00:00:00

Post Your Answers

User Email:

User Name:

Related SCJP1.5 chap2 Links

SCJP1.5 chap2 interview questions and answers for experienced and fresher