answersLogoWhite

0


Best Answer

The final keyword can be used to modify a class, method, or variable.

When used on a variable, it means that variable cannot be changed once set.
When used on a method, it means that no subclasses may override that method.

User Avatar

Wiki User

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

Wiki User

11y ago

The final keyword in Java has more in common with a C++ reference than it does with a C++ const. That is, a reference may only be assigned once, but the referenced object may still be modified. A C++ reference is the same as a constant pointer (rather than a pointer to const), insofar as the pointer cannot be modified, but the memory being pointed to can. This emulates some of the behaviour of the Java final keyword. But while a C++ const can easily be cast to a volatile, you simply cannot do that in Java. Moreover, a Java final class cannot be sub-classed, you simply cannot do that in C++. Comparing Java final to C++ const is somewhat pointless since they have absolutely nothing whatsoever in common; the list of differences could fill a book.

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What is difference between constant in c plus plus and final in java?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

WAP to show the difference between a variable and static variable?

difference between constant and static variables in java


What is the difference between a constant and a variable in java programming language?

A constant in Java is defined using the "final" modifier. For instance: final double Density_Of_Water = 1.000; would set Density_Of_Water to 1.000. This value can not be modified throughout the program because "final" told the compiler that this value would not change. A variable however, can be changed by the user throughout the program.


What is the difference between variables and constants in java?

constant is does not change the value of during the excution of programvariable it changes the value during the excution of program


What is difference between java 2 and java 5?

They are different versions. Java 5 is newer than Java 2. Think of it like the difference between the Playstation 1 and the Playstation 3.


What is public static final variable in java?

-Public to all - Static to access with Class Name - Final to change( constant and not alowed to change) Just use it along with class name. (As implied above, a 'public static final' variable in Java is what other languages would call a Constant. )


Major difference between c and java?

Java is object oriented, C is not...


What is the difference between connectivity in java?

kamina


What is difference between connectivity in java?

kamina


What is the main difference between UNIX and JAVA?

Unix is an operating system, Java is a language.


Difference between recordset and resultset in java?

Rowset


What is the difference between JAD and JAR?

JAD-Java Application Description JAR-Java archive


Is unsigned integer constant are available in Java?

yes use the final keyword, normally variables declared final use all capital letters but this is not required final int A = 10;