Sunday, December 8, 2013

How to understand the key differences between them
Examples that help us to understand the differences !
share|improve this question
6 
You can easily google this out. This is not the place to do your homeworks. –  Umang Mehta Sep 8 at 5:29
1 
Could you please open up any of the Java books and look at the Inheritance Chapter. Looking at the java reserved key words section will also, give you good answers. If you know that you have to look for final. Let me make it easier for you, open google and type significance of the keyword final in java. – dharam Sep 8 at 5:34
2 
Don't get the idea .... why this question is being downvoted ? .... though its a simple question & can be googled .... still if its not in stackoverflow already asked questions .... its a good question to be asked ! .... Also answers in stackoverflow are much better in than google ,blogs and much clear to understand here ! – NewBie Sep 8 at 5:48
 
You can add finally and finalize to the interview question. I assume you know what the difference between a variable, a method and a class is. –  Peter Lawrey Sep 8 at 7:02
add comment

closed as too broad by kcoppockLuiggi MendozaEJPRadim Köhler,Tushar Gupta Sep 8 at 5:50

There are either too many possible answers, or good answers would be too long for this format. Please add details to narrow the answer set or to isolate an issue that can be answered in a few paragraphs.If this question can be reworded to fit the rules in the help center, please edit the question.
up vote10down voteaccepted

Final Variable:

final variable means we can't change its value

Final method:

If we declare a method as final, we can't override the method.

Final Class:

If we declare a class as final, that means we can't extend the class or in other words we can't make a sub-class of it
Example of final variable:
final int distance=8;
distance = 7; // because of the final declaration this line is an error
Example of final method:
public class A {
    final void LasVegas()
    {
    }
}

public class B extends A {
        final void LasVegas()  // because of the final declaration in A, this is illegal
        {
        }
    }
Example of final class:
final class LasVegasClass {
}

class AnotherClass extends LasVegasClass { // illegal because LasVegasClass is final
}
share|improve this answer
add comment

No comments: