The difference between abstract classes and interfaces, activity depth inheritance

Java abstract class

1, abstract modification using the abstract class; 2, abstract class can not be instantiated, i.e., can not use the new keyword to instantiate an object; 3, containing abstract method (using a modified method of the abstract keyword) of the class is abstract, abstract must be used key modification; 4, abstract class may contain abstract methods, may not include abstract methods, a method can be a specific abstract class; 5, if a subclass implements all the abstract parent class (abstract class), then the subclasses may not necessarily be an abstract class, or is an abstract class; 6, abstract methods abstract class only method body, there is no concrete realization;

Java Interface

Interface: 1, interface interface modification; 2, the interface can not be instantiated; 3, a class can inherit a class, but can implement multiple interfaces; 4, the interface methods are abstract methods; 5, the interface can not contain example domain or a static method (static method must be implemented, the interface is an abstract method, can not be achieved)

 

activity depth inheritance 

 

activity  ---ContextThemeWrapper---ContextWrapper---Context

 

Context:

public abstract class Context {}

Is an abstract class, there are some operations and file operations, and so a lot of activity

E.g:

public abstract void startActivity(Intent var1);

public abstract void startActivity(Intent var1, Bundle var2);

Guess you like

Origin blog.csdn.net/qq_38998213/article/details/104928430