JAVA笔试:一道综合考察题(内部类,传值调用,多态)

xiaoxiao2021-02-28  27

public class Tree { private static String tree = "tree"; String getTree() { return tree; } public static class Elm extends Tree { private static String tree = "elm"; public static void main(String[] args) { new Elm().go(new Tree()); } void go(Tree t) { String s = t.getTree() + Elm.tree + tree + (new Elm().getTree()); System.out.println(s); } } }

A. elm elm elm elm B. tree elm elm elm C. tree elm elm tree D. elm elm tree elm

正确答案:C

转载请注明原文地址: https://www.6miu.com/read-2627926.html

最新回复(0)