Java object oriented programming (encapsulation / Inheritance / polymorphism) instance parsing

This paper mainly introduces the analysis of three object-oriented feature examples. Let's see the specific content.

encapsulation

Encapsulate a teacher and student class

Student class

Test class

Output results:

Name = Zhang San, age = 21, course = [Asda, yes, probably, too tempting], interest = playing name = Wang Wu, professional direction = Asda, course taught = Asda, teaching age = 99

inherit

Define play, taoistprime, master, warrior

Test class

Output results:

polymorphic

Server, client interaction

LoginListener

MyLoginListener

Server

Test class

Output results

summary

The above is about java object-oriented programming in this article (encapsulation, inheritance, polymorphism) all the contents of instance parsing, hope to help you. Interested friends can continue to refer to this site: parsing synchronized locked objects of Java programming, object-oriented programming ideas of Java language, detailed explanation of object instances, etc. if there are deficiencies, please leave a message. Thank you for your support to this site!

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>