Not much to say, the first paragraph of code.
Public classabstract{ Public Static voidMain (string[] args) {Cl2 c=NewCl2 (); C.method (); }}Abstract classabc{ Public Abstract voidmethod (); }classCl2extendsabc{ Public voidmethod () {System.out.println ("Concrete Method"); }}
There can be no abstract method in an abstract class.
Like what
Abstract class abc{ publicvoid method () { System.out.println (" The method of the abstract class surface can be specific ");} }
This is an abstract class, but his method is specific, it is possible, no error.
But if
class abc{ abstractpublicvoid method ();
This is an error, because an abstract method must be an abstract class.
----------------------------------------
class extends abc{ publicvoid method () { System.out.println ("specific class") ); }}
At this point the ABC class is inherited, and the Cl2 class is a concrete class. Are we in the region a class is abstract or specific, that is, to see the abstract keyword
If there is this keyword, he is an abstract class, not a specific class, so the above code in Cl2 is a concrete class.
Go on
Abstract class abc{ abstractpublicvoid method (); class extends abc{ }
Here will be an error, Cl2 no keyword abstract so he is a concrete class, inside the method must be specific, but he inherited the
ABC class, has an abstract method, so will error, so need to Cl2 inside the specific Mehod method.
Of course, the subclass of the abstract class can also be an abstract class
Like what
Abstract class abc{ abstractpublicvoid method (); Abstract class extends abc{
Cl2 is an abstract class that inherits the ABC class and has an abstract method in the ABC class.
But he doesn't need to be specific, because he's an abstract class himself.
------------------------------------
Above are some points of attention in abstract class.
In general, an abstract class can have no abstract method, but abstract methods must be abstract classes, and concrete classes must be concrete methods.
Freshman dog Beginner, no, please understand
Java abstract class