“Résumé vs final” Réponses codées

Résumé vs final

1-Abstract method should be overriden
 -Final method can't be overriden
2-Abstract method can be inherited
 -Final can't be inherited
3-Abstract can be w/o implementation
 -Final must have implemetation
4-Abstract we can't create objects
 -Final we can create objects(string)
5-Abstract can't be instantiated
 -Final can be instantiated
Obedient Ocelot

Résumé vs final


public final class MyClass { //final not required but clearly states intention
    //private default constructor ==> can't be instantiated
    //side effect: class is final because it can't be subclassed:
    //super() can't be called from subclasses
    private MyClass() {
        throw new AssertionError()
    }

    //...
    public static void doSomething() {}
}

Crowded Caterpillar

Réponses similaires à “Résumé vs final”

Questions similaires à “Résumé vs final”

Plus de réponses similaires à “Résumé vs final” dans Java

Parcourir les réponses de code populaires par langue

Parcourir d'autres langages de code