[] Object-oriented abstract class wherein

Abstract methods:

  The abstract modification method, there is no method body, only a statement. The definition of a "standard" is to tell the subclass must give an abstract method to provide an implementation.

 

Abstract class:

  Contains abstract methods of the class is an abstract class. Abstract methods defined by the specification and claims define specific subclass must implement. Through abstract class, we can do the design strictly limited subclass of the more general between subclasses.

 

Abstract class Code Example:

Animal class abstract 
{ 
// abstract class 
	abstract public void shout (); // abstract method 
} 

class Dog the extends Animal 
 { 
// subclass must abstract parent class implementation or the compiler errors 
	 public void Shout () 
	 { 
		 the System.out. the println ( "bark Wang!"); 
	 } 
	 public void seeDoor () 
	 { 
		 System.out.println ( "gatekeeper in ..."); 
	 } 
} 
// test abstract class 
/ * 
public class TestAbstractClass 
{ 
	public static void main ( String [] args) { 
		Dog A Dog new new = (); 
		a.shout (); 
		a.seeDoor (); 
	} 
} 
* /

  

Guess you like

Origin www.cnblogs.com/sdrbg/p/11222080.html