E5CB java_lang_specs/abstract_class at main · HunorVadaszPerhat/java_lang_specs · GitHub
[go: up one dir, main page]

Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

readme.md

Abstract class

Methods in abstract class:

  • Abstract

    • access modifiers for abstract methods can be -> default, public, protected EXCEPT private: abstract_method
  • Non-abstract

    • access modifiers for non-abstract methods can be -> default, public, private, protected: non_abstract_method

Fields in abstract class:

  • Non-static and non-final

    abstract_class_non_static_non_final
  • Final

    abstract_class_final
  • Static

    abstract_class_static
  • Static final

    abstract_static_final

Constructors in abstract class:

  • Constructor in abstract class

    abstract_class_constructor
  • Usage of constructor in non-abstract class

    abstract_class_usage_of_constructor_in_non_abstract_class

Abstract class vs interface

Methods

  • abstract class: can be abstract and nont abstract
  • interface: can be abstract, default, static

Access modifiers

  • abstract class: methods can have private, public, default and protected
  • interface: methods are by default public abstract only

Variables

  • abstract class: can be non-static and non-final
  • interface: by default are public static final

Constructor

  • abstract class: can have constructor
  • interface: cannot have constructor

Multiple inheritance

  • abstract class: can extend at most one class and implement one or more interfaces
  • interface: can only extend one or more interfaces

Extends/Implements

  • abstract class: abstract classes are extended by the sub-class. Sub-classes need to provide implementation for all abstract methods or class shall be declared as abstract as well
  • interface: interface is implemented by a class and the implementing class needs to provide implementation for all methods. If class does not implement all methods class shall be declared as abstract
0