题目内容

给出以下代码,请问该程序的运行结果是为什么?public class Example {public static void main(String args[]){String s1 = “abc”;String s2 = “abc”;if(s1==s2)System. out. println("1");elseSystem . out . println("2") ;if (s1 . equals (s2))System . out . println("3") ;elseSystem . out . println("4") ;}}请选择所有正确答案

A. 打印输出 1
B. 打印输出 2
C. 打印输出 3
D. 打印输出 4

查看答案
更多问题

给出以下代码,请问该程序的运行结果是什么?public class Example{public static void main (String args [] ) {String s1 = "abc";String s2 = new String("abc");if (s1 == s2)System . out . println("1");elseSystem . out . println("2");if (s1 . equals (s2))System . out . println("3");elseSystem . out . println("4");}}

A. 打印输出 1
B. 打印输出 2
C. 打印输出 3
D. 打印输出 4

给出以下代码,请问该程序的运行结果是什么?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))

答案查题题库