“Abstrak vs final” Kode Jawaban

Abstrak 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

Abstrak 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

Jawaban yang mirip dengan “Abstrak vs final”

Pertanyaan yang mirip dengan “Abstrak vs final”

Lebih banyak jawaban terkait untuk “Abstrak vs final” di Java

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya