answersLogoWhite

0


Best Answer

The final keyword in JAVA means that the class can no longer be derived, i.e. it cannot be used as a base class for a new child class.

If you declare a method as final, this method cannot be overridden in any of the child class that may extend this class.

User Avatar

Wiki User

14y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

14y ago

You cannot. An Interface can be only public or abstract.

A final keyword indicates - the methods cannot be overridden whereas in an interface you expect the implementing class to write all the methods. So logically it shouldn't be possible which Java does.

When you compile a interface with final keyword - the compiler wont let you compile.

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What if a final keyword is applied to a function?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

What is the meaning of final keyword in Cplusplus language?

Actually, when you declare a variable as 'final' then the value assingned to the variable does not changes throughout the program. For example, class d { public final int n=10; } In this class d, the value of 'n' would be '10' & its value cannot not be altered by any function declared within the class.


What are the usages of keyword final in java?

It's a built-in keyword that defines an entity that cannot be later modified. It can be used in different aspects within your code (like setting a 'final' class, method (function), or variable).


Which is the keyword used to limit the scope of a function to the file in which it resides?

Declare the function static.


What does the final keyword mean in front of a variable a method a class?

When used in a class declaration, the final keyword means the a class can't be subclassed. In other words, no other class can extend (inherit) a final class, and any attempts to do so will give you a compiler error. The final keyword prevents a method from being overridden in a subclass. Final methods are usually placed in classes where you don't want anyone who is extending your code to meddle with a certain piece of functionality. Declaring a variable with the final keyword makes it impossible to reassign a different value to that variable once it has been initialized with an explicit value -


Python keyword indicates the start of a function definition?

The word "def", short for definition starts a function.

Related questions

What happens if a final keyword is applied to function?

A final function can not be overridden for any subclass. This means any class which extends our class with a final function can not redefine the functionality of our final function. if you have: public class Top{ public final doSomething(){ System.out.println("hi"); } } You can not do this: public class Buttom extends Top{ public final doSomething(){ // NO! YOU CAN'T CHANGE THIS FUNCTION System.out.println("good-bye"); // THIS CODE DOES NOT COMPILE } }


What happens if a final keyword is applied to identifier?

The final keyword indicates that a variable (identifier) can not change his value. In case the variable refers to a reference variable (an object) the values of variables inside (the object) can change but the reference can be reassigned (to another object).


What is the meaning of final keyword in Cplusplus language?

Actually, when you declare a variable as 'final' then the value assingned to the variable does not changes throughout the program. For example, class d { public final int n=10; } In this class d, the value of 'n' would be '10' & its value cannot not be altered by any function declared within the class.


What are the usages of keyword final in java?

It's a built-in keyword that defines an entity that cannot be later modified. It can be used in different aspects within your code (like setting a 'final' class, method (function), or variable).


How does the final keyword affect the behavior of Object type in Java?

In Java, the final keyword specifies that the object created cannot be further redefined or derived.


What is the final keyword in Java?

The final keyword precedes a declared constant which after Instantiation cannot be modified. Examples. final double PI = 3.14; PI = 1234; // does not compile //or final double ONE; ONE = 1; // Instantiated ONE = 2; // does not compile ---------------------------------------- final keyword can also apply to a method or a class. When applied to a method - it means the method cannot be over-ridden. Specially useful when a method assigns a state that should not be changed in the classes that inherit it, and should use it as it is (not change the method behaviour). When applied to a class it means that the class cannot be instantiated. A common use is for a class that only allows static methods as entry points or static final constants - to be accessed without a class instance. A good example is Java's: public final class Math extends Object


Can you make a class final in java?

yes of course... using the final keyword


Which keyword is used to make function call faster in c?

Inline Function


Which is the keyword used to limit the scope of a function to the file in which it resides?

Declare the function static.


Which is the keyword used to limit the scope of the function to the file in which it is reside?

Declare the function static.


When do you declare a class as final?

By using the final keyword in the class declaration statement. Ex: public final class Test {...}


What does the new function do?

The new keyword creates a new Object.