Question :What does it mean that a class or member is final? (CoreJava)
Answer :A final class can no longer be subclassed. Mostly this is done for security
reasons with basic classes like String and Integer. It also allows the
compiler to make some optimizations, and makes thread safety a little
easier to achieve.
Methods may be declared final as well. This means they may not be
overridden in a subclass.
Fields can be declared final, too. However, this has a completely different
meaning. A final field cannot be changed after it's initialized, and it must
include an initializer statement where it's declared. For example,
public final double c = 2.998;
It's also possible to make a static field final to get the effect of C++'s const
statement or some uses of C's #define, e.g.
public static final double c = 2.998;
www.interviewhelper.org is a hope for all the Job seekers. Users can find unlimited here. These range from technical to HR, from functional to behavioral. www.interviewhelper.org contains in the fields like Ajax,VB,Networking,Sharepoint,JEE,Perl,Javascript,Bioinformatics,Classic ASP,Unix,Linux,Accounting,Oracle DBA,Microprocessor,Bluetooth,jms,jme,.net framework,ABAP,ASP,ASP.net,Basic .net Framework,Interview Questions,C language,C++,database,Oracle,Java,PHP,LAMP,SAP etc.
Tuesday, March 10, 2009
What does it mean that a class or member is final? (CoreJava)
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment