给出以下代码片段,请问以下哪些表达式的结果为true?Double d1=new Double (10.0);Double d2=new Double (10.0);int x = 10;float f=10.0f;
A. d1==d2;
B. d1==x;
C. f==x;
D. d1.equals(d2)
E. 以上均不对。
查看答案
给出以下代码,请问该程序的运行结果是为什么?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))