题目内容

给出以下代码,请问该程序的运行结果是什么?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. printin (“Pinc”);if (tree instanceof Tree)System. out. printin (“Tree”);if (tree instanceof Oak);System. out. printin (“Oak”);elseSystem. out. println (“Oops”);}}

A. 打印输出Pinc
B. 打印输出Tree
C. 打印输出Oak
D. 打印输出Oops
E. 无内容输出。

查看答案
更多问题

给出以下代码,请问以下哪些选项会抛出NullPointerException异常来?String s=null;

A. if ((s!=null)&(s .length( )>0))
B. if ((s!=null)&&(s .length( )>0))
C. if ((s!==null)︱(s .length( )==0))
D. if ((s!==null)‖(s .length( )==0))

给出以下代码,请问哪些表达式运行期异常抛出?int = 0 , j = 1;请选择所有正确答案:

A. if((i==0)‖(j/i==1))
B. if((i==0)︱(j/i==1))
C. if((i!=0)&&(j/i==1))
D. if((i!=0)&(j/i==1))

以下哪些描述是正确的?

A. 如果package语句存在,则必须出现在源文件的非空白首行。
B. 如果import语句存在,则必须出现在源文件的非空白首行。
C. 如果main()方法存在,则必须出现在源文件的非空白首行。
D. 如果在源文件中声明了一个public接口,则其名称必须和源文件名一致。

以下哪些是正确的Java注释形式?

A. \\ This is a comment.
B. /*This is a comment.*/
C. /**This is a comment.*/
D. \*This is a comment.*\

答案查题题库