{"id":725,"date":"2023-03-23T21:50:23","date_gmt":"2023-03-23T13:50:23","guid":{"rendered":""},"modified":"2023-03-23T21:50:23","modified_gmt":"2023-03-23T13:50:23","slug":"Java \u62bd\u8c61\u548c\u63a5\u53e3\u533a\u522b","status":"publish","type":"post","link":"https:\/\/bianchenghao6.com\/725.html","title":{"rendered":"Java \u62bd\u8c61\u548c\u63a5\u53e3\u533a\u522b"},"content":{"rendered":"


\n <\/head>
\n <\/p>\n

\n

Java \u62bd\u8c61\u548c\u63a5\u53e3\u533a\u522b<\/h1>\n<\/p><\/div>\n
\n \u62bd\u8c61\u7c7b\u548c\u63a5\u53e3\u90fd\u7528\u4e8e\u5b9e\u73b0\u62bd\u8c61\uff0c\u6211\u4eec\u53ef\u4ee5\u5728\u5176\u4e2d\u58f0\u660e\u62bd\u8c61\u65b9\u6cd5\u3002\n <\/div>\n
\n \u4f46\u662f\u62bd\u8c61\u7c7b\u548c\u63a5\u53e3\u4e4b\u95f4\u90fd\u65e0\u6cd5\u5b9e\u4f8b\u5316\u3002\n <\/div>\n\n\n\n\n\n\n\n\n\n\n\n\n
\u62bd\u8c61\u7c7b<\/td>\n\u63a5\u53e3<\/td>\n<\/tr>\n
1)\u62bd\u8c61\u7c7b\u53ef\u4ee5\u5177\u6709\u62bd\u8c61\u548c\u975e\u62bd\u8c61\u7684\u65b9\u6cd5<\/strong>\u3002<\/td>\n\u63a5\u53e3\u53ef\u4ee5\u5177\u6709\u4ec5\u62bd\u8c61<\/strong>\u65b9\u6cd5\u3002\u4eceJava 8\u5f00\u59cb\uff0c\u5b83\u8fd8\u53ef\u4ee5\u5177\u6709\u9ed8\u8ba4\u548c\u9759\u6001\u65b9\u6cd5<\/strong>\u3002<\/td>\n<\/tr>\n
2)\u62bd\u8c61\u7c7b\u4e0d\u652f\u6301\u591a\u91cd\u7ee7\u627f<\/strong>\u3002<\/td>\n\u63a5\u53e3\u652f\u6301\u591a\u91cd\u7ee7\u627f<\/strong>\u3002<\/td>\n<\/tr>\n
3)\u62bd\u8c61\u7c7b\u53ef\u4ee5\u5177\u6709\u6700\u7ec8\u53d8\u91cf\uff0c\u975e\u6700\u7ec8\u53d8\u91cf\uff0c\u9759\u6001\u53d8\u91cf\u548c\u975e\u9759\u6001\u53d8\u91cf<\/strong>\u3002<\/td>\n\u63a5\u53e3\u53ea\u6709\u9759\u6001\u53d8\u91cf\u548c\u6700\u7ec8\u53d8\u91cf<\/strong>\u3002<\/td>\n<\/tr>\n
4)\u62bd\u8c61\u7c7b\u53ef\u4ee5\u63d0\u4f9b\u63a5\u53e3\u7684\u5b9e\u73b0<\/strong>\u3002<\/td>\n\u63a5\u53e3\u65e0\u6cd5\u63d0\u4f9b\u62bd\u8c61\u7c7b\u7684\u5b9e\u73b0<\/strong>\u3002<\/td>\n<\/tr>\n
5)\u62bd\u8c61\u5173\u952e\u5b57<\/strong>\u7528\u4e8e\u58f0\u660e\u62bd\u8c61\u7c7b\u3002<\/td>\n interface\u5173\u952e\u5b57<\/strong>\u7528\u4e8e\u58f0\u660e\u63a5\u53e3\u3002<\/td>\n<\/tr>\n
6)\u62bd\u8c61\u7c7b<\/strong>\u53ef\u4ee5\u6269\u5c55\u53e6\u4e00\u4e2aJava\u7c7b\u5e76\u5b9e\u73b0\u591a\u4e2aJava\u63a5\u53e3\u3002<\/td>\n \u63a5\u53e3<\/strong>\u53ea\u80fd\u6269\u5c55\u53e6\u4e00\u4e2aJava\u63a5\u53e3\u3002<\/td>\n<\/tr>\n
7)\u53ef\u4ee5\u4f7f\u7528\u5173\u952e\u5b57\" extends\"\u6269\u5c55\u62bd\u8c61\u7c7b<\/strong>\u3002<\/td>\n\u53ef\u4ee5\u4f7f\u7528\u5173\u952e\u5b57\" implements\"\u5b9e\u73b0\u63a5\u53e3<\/strong>\u3002<\/td>\n<\/tr>\n
8)Java \u62bd\u8c61\u7c7b<\/strong>\u53ef\u4ee5\u5177\u6709\u79c1\u6709\uff0c\u53d7\u4fdd\u62a4\u7b49\u7c7b\u6210\u5458\u3002<\/td>\n\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0cJava\u63a5\u53e3\u7684\u6210\u5458\u662f\u516c\u5171\u7684\u3002 <\/td>\n<\/tr>\n
9)\u793a\u4f8b: <\/strong>
\u516c\u5171\u62bd\u8c61\u7c7bShape {
\u516c\u5171\u62bd\u8c61void draw();
} <\/td>\n
\u793a\u4f8b: <\/strong>
\u516c\u5171\u63a5\u53e3Drawable {
void draw();
} <\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n
\n \u7b80\u5355\u6765\u8bf4\uff0c\u62bd\u8c61\u7c7b\u5b9e\u73b0\u90e8\u5206\u62bd\u8c61(0\u5230100\uff05)\uff0c\u800c\u63a5\u53e3\u5b9e\u73b0\u5b8c\u5168\u62bd\u8c61(100\uff05)\u3002\n <\/div>\n

Java\u4e2d\u62bd\u8c61\u7c7b\u548c\u63a5\u53e3\u7684\u793a\u4f8b<\/h3>\n
\n \u8ba9\u6211\u4eec\u770b\u4e00\u4e2a\u7b80\u5355\u7684\u793a\u4f8b\uff0c\u5176\u4e2d\u6211\u4eec\u540c\u65f6\u4f7f\u7528\u4e86\u63a5\u53e3\u548c\u62bd\u8c61\u7c7b\u3002\n <\/div>\n
\n
 \/\/Creating interface <\/span>that has 4 methodsinterface A{
    void a();
    \/\/bydefault, public <\/span>and abstractvoid b();
    void c();
    void d();
}
\/\/Creating abstract <\/span>class <\/span>that provides the implementation of one method of A interfaceabstract class <\/span>B implements <\/span>A{
    public void <\/span>c(){
        System.out.println<\/span>(\"I am C\"<\/span>);
    }
}
\/\/Creating subclass <\/span>of abstract <\/span>class, now we need to provide the implementation of rest <\/span>of the methodsclass <\/span>M extends <\/span>B{
    public void <\/span>a(){
        System.out.println<\/span>(\"I am a\"<\/span>);
    }
    public void <\/span>b(){
        System.out.println<\/span>(\"I am b\"<\/span>);
    }
    public void <\/span>d(){
        System.out.println<\/span>(\"I am d\"<\/span>);
    }
}
\/\/Creating a test class <\/span>that calls the methods of A interfaceclass <\/span>Test5{
    public <\/span>static void <\/span>main(String args[]){
        A a=new M();
        a.a<\/span>();
        a.b<\/span>();
        a.c<\/span>();
        a.d<\/span>();
    }
}
<\/span><\/code><\/pre>\n<\/p><\/div>\n
\n \u8f93\u51fa:\n <\/div>\n
\n
 I am a I am b I am c I am d
<\/span><\/code><\/pre>\n<\/p><\/div>\n

<\/body>
\n<\/html><\/p>\n","protected":false},"excerpt":{"rendered":"Java \u62bd\u8c61\u548c\u63a5\u53e3\u533a\u522bzh-cn","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[111],"tags":[],"class_list":["post-725","post","type-post","status-publish","format-standard","hentry","category-java-jichu"],"_links":{"self":[{"href":"https:\/\/bianchenghao6.com\/wp-json\/wp\/v2\/posts\/725"}],"collection":[{"href":"https:\/\/bianchenghao6.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/bianchenghao6.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/bianchenghao6.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/bianchenghao6.com\/wp-json\/wp\/v2\/comments?post=725"}],"version-history":[{"count":0,"href":"https:\/\/bianchenghao6.com\/wp-json\/wp\/v2\/posts\/725\/revisions"}],"wp:attachment":[{"href":"https:\/\/bianchenghao6.com\/wp-json\/wp\/v2\/media?parent=725"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/bianchenghao6.com\/wp-json\/wp\/v2\/categories?post=725"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/bianchenghao6.com\/wp-json\/wp\/v2\/tags?post=725"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}