java java in the final keywords and abstract classes

1.final keyword

final --- finally the final final can not be changed

The final effect:

) .1. Final modified variable becomes constant, the value no longer changes
) .2. Final modification methods, subclasses can override
) .3. Final modified class , you can not have subclasses method (without use of the final final modified, nor can it be rewritten)

final constructor can not be modified

Introduction:

Java provides what final constants, methods, like
 the Math
 System
 String
 StringBuffer

final modification of the basic data types, can only be assigned a value, the assignment can not follow

2. abstract class

abstract-- abstract, abstract (English translation)

Definition: java, abstract class contains a method called an abstract class, an abstract class can not generate the object;

Summary 1: abstract class
* 1. abstract modified
* 2 can not new instance of
* 3. The abstract class constructor must create subclasses of objects when using
* 4. An abstract class least 0 abstract method , up to ( All methods are abstract) abstract methods
*
* 2 summarizes: abstract method
* 1. abstract modification
* 2. abstract method declarations only, no method body
* 3.public abstract void shout () { } is not an abstract method
* 4. the method of subclasses must override the abstract parent class, it does not override prompt compilation error; or subclass can be defined as an abstract class
* 5.override implements implement override
* parent class is abstract, subclass implementation ; parent class is not an abstract, a subclass can override
* = new new 6.Animal Dog Dog ();
* upwardly polymorphic transition, an abstract class is instantiated implementation subclass instantiation by

Action abstract class
* 1. An abstract class is a class first, generally used as a parent class is reflected is-a is-a relationship Animal Dog
* 2. abstract class can not be instantiated
* 3. abstract subclass must implement the method
4. * abstract class is a template model. Abstract class provides a common template for all sub-categories, sub-categories can be expanded based on this template.

Guess you like

Origin www.cnblogs.com/zimo-bwl1029-s/p/11278830.html
Recommended