Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

difference between abstract class and 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
Comment

abstract 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() {}
}

Comment

PREVIOUS NEXT
Code Example
Java :: Java Using forName() method 
Java :: how to make a char uppercase in java 
Java :: java int to int array 
Java :: java discord bot get id of message it just sent 
Java :: how to find the highest power of 2 that divides a number? 
Java :: convert string to byte java 
Java :: java get cunnect date time 
Java :: java how to override a private method 
Java :: array to list 
Java :: java string builder 
Java :: java queue 
Java :: how to convert an ascii number to character in java 
Java :: java print output 
Java :: write json string to file in java 
Java :: print queue in java 
Java :: Service vs Intent Service 
Java :: system.out.print two dimensional array 
Java :: get month from int java 
Java :: shell sort java 
Java :: java find time between two dates 
Java :: turn ascii into text javascriot 
Java :: java sort list of strings 
Java :: How to perform a breadth first search through a binary tree, in Java? 
Java :: war file vs jar file 
Java :: hashmap foreach 
Java :: SendKeys issues with numbers(Int) 
Java :: change button text onclick java 
Java :: clear text field in java 
Java :: public String toString() { 
Java :: string array to string java 
ADD CONTENT
Topic
Content
Source link
Name
6+2 =