ThreadTest,ExtendsTest

This commit is contained in:
LingZhaoHui 2021-05-16 18:11:35 +08:00
parent a2d416fdd2
commit c090a72264
2 changed files with 61 additions and 0 deletions

View File

@ -0,0 +1,36 @@
package com.zeekling.exten;
/**
* @author zeekling
* @apiNote https://www.nowcoder.com/question/next?pid=30695833&qid=15977&tid=44372102
* @since 2021-05-16
*/
public class ExtendsTest {
public static void main(String[] args) {
Base base = new Son();
base.method();
//base.methodB();
}
}
class Base
{
public void method()
{
System.out.println("Base");
}
}
class Son extends Base
{
public void method()
{
System.out.println("Son");
}
public void methodB()
{
System.out.println("SonB");
}
}

View File

@ -0,0 +1,25 @@
package com.zeekling.thread;
/**
* @author zeekling
* @apiNote https://www.nowcoder.com/question/next?pid=30695833&qid=4339&tid=44372102
* @since 2021-05-16
*/
public class ThreadTest {
public static void main(String args[]) {
Thread t = new Thread() {
public void run() {
dianping();
}
};
t.run();
System.out.print("dazhong");
}
static void dianping() {
System.out.print("dianping");
}
}