The Artima Developer Community
Sponsored Link

Java Answers Forum
Final Classes in Java

1 reply on 1 page. Most recent reply: Jan 12, 2005 10:37 PM by Yogesh

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 1 reply on 1 page
JavaAdd Ict

Posts: 5
Nickname: javaaddict
Registered: May, 2004

Final Classes in Java Posted: Jan 12, 2005 12:32 AM
Reply to this message Reply
Advertisement
One of my colleagues read this in a book of Data Structures, that in Java if a class is made as final(assuming that its not going to be inherited any further), then it increases the run time performance.

Can someone pls explain how does this happen? How is the bytecode of a final class is different from that of a normal class and in what way is its behaviour different at run time?

Thanks.


Yogesh

Posts: 19
Nickname: kyogesh
Registered: Sep, 2004

Re: Final Classes in Java Posted: Jan 12, 2005 10:37 PM
Reply to this message Reply
hi
inheritance involve key issue of polymorphism which is related to latebinding or dynamic binding.

if a class is final it cannot be inherited. its all methods are also final that means methods cannot be overridden. so no need of dynamic binding. only static binding
and dynamic binding has more overheads than static binding. hence if a class or a method is final only static binding is involved (less overheads at runtime). thus improved performance is achieved.

I don't know about '.class' file structure. check this link :http://www.shsu.edu/~csc_tjm/summer2000/cs278/inheritance.html

Flat View: This topic has 1 reply on 1 page
Topic: printout from applet varies depending on server Previous Topic   Next Topic Topic: Regular Expressions in WebSphere

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use