hc学习平台

 找回密码
 立即注册
搜索
热搜: 活动 交友 javakc
 › lijiaoluo › 日志

请问该程序的运行结果是什么  

2022-02-11 08:23:55 查看(164) 回复(0)

class  Tree  {
}

class  Pinc  extends  Tree  {
}

class  Oak  extends  Tree  {
}

public  class  Forest  {
  public  static  void  main(String[]  args)  {
    Tree  tree  =  new  Pinc();
    if  (tree  instanceof  Pinc)
      System.out.println("Pinc");
    if  (tree  instanceof  Tree)
      System.out.println("Tree");
    if  (tree  instanceof  Oak)
      System.out.println("Oak");
    else
      System.out.println("Oops");
  }
}
A、无内容输出
B、打印输出Oops
C、打印输出Oak
D、打印输出Tree
E、打印输出Pinc
BDE

评论 (0 个评论)

facelist

全部作者的其他最新日志



站点统计|举报|Archiver|手机版|小黑屋|Comsenz Inc.

GMT+8, , Processed in 0.195171 second(s), 9 queries .

Powered by javakc! X1.0

© 2004-2014 javakc

f1208.com 备案号:京ICP备14030918号-1

返回顶部