Object-oriented multi-state extension instances and object-oriented multi-state instances
/**
*Note: The following statements are non-executable. Cannot run
* Created by rabbit on 2014-07-29.
* Requirements
* Perform database operations
*
* 1. Connect to the database
* Two Connection Methods
* A. JDBC (java database connection)
* B. Hibernate (Framework connection)
*
* 2. operate databases
* C create r read u update d delete
*
* 3. Disconnect the database
*
* UserinfoDAO
* DAO data access object
*/
Interface userinfoDAO
{
Public void add (User user );
Public void delete (User user );
}
Class userinfoJDBC implements userinfoDAO
{
Public void add (User user)
{
1. Connect to the database through JDBC;
2. Use SQL statements to add data;
3. Close the connection;
}
Public void delete (User user)
{
1. Connect to the database through JDBC;
2. Use SQL to add a statement to delete data;
3. Close the connection;
}
}
Class userinfoHibernate implements userinfoDAO
{
Public void add (User user)
{
1. Connect Hibernate to the database;
2. Use SQL statements to add data;
3. Close the connection;
}
Public void delete (User user)
{
1. Connect Hibernate to the database;
2. Use SQL to add a statement to delete data;
3. Close the connection;
}
}
Public class DBOperate {
Public static void main (String [] args)
{
UserinfoDAO ui = new userinfoDAO;
Ui. add (User user );
Ui. delete (User user );
}
}
What Is Object-Oriented polymorphism?
The concept of object-oriented programming has always been pursued by programmers. Previous programming was process-oriented and cannot be used for large-scale projects. object-Oriented programming is a revolution. it is more suitable for people's thoughts and thoughts, rather than Programming Based on Machine language ideas! In C #, everything is an object! In fact, it is not hard to understand the object. For example, if you are looking for a wife, what is your wife, how old is it, what's your surname, what's your job, and how many boyfriends have you made, and so on.
When talking about type conversion, this should be needless to say!
To forcibly convert a parent class object to a subclass object, the precondition is that the parent class object has a subclass object value, that is, the subclass object has been assigned to the parent class variable!
///
If the parent class object is converted to a subclass object, is the method called the parent class or subclass (or attribute )?
This is hard to say. It may take some time to make it clear! There are many questions, such as whether to hide, override, and parent class methods in the subclass. Besides, whether the parent class is an abstract class or an interface should be analyzed in detail!
It is best to paste your code to help you analyze it!
The above is my understanding. If it is incorrect, please try again!
Java object-oriented encapsulation inheritance Polymorphism
Encapsulation: write all the methods into a class,
Inheritance: there are people, dogs, cats, etc.
Polymorphism: There are cognominal functions, but the function parameters are different!
These are simple understandings!