题目详情
当前位置:首页 > 职业培训考试
题目详情:
发布时间:2024-08-30 21:51:56

[单项选择] class A {   public String toString () {   return “4”;   }   }   class B extends A {   8. public String toString () {   return super.toString() + “3”;   }   }   public class Test {   public static void main(Stringargs) {   System.out.printIn(new B());   }   }   What is the result?()  
A.  Compilation succeeds and 4 is printed.
B.  Compilation succeeds and 43 is printed.
C.  An error on line 9 causes compilation to fail.
D.  An error on line 14 causes compilation to fail.
E.  Compilation succeeds but an exception is thrown at line 9.

更多"class A {   pub"的相关试题:

[单项选择] 现有代码片段:      String  s="123";      String sl=S+456;  请问sl的结果是哪项?()     
A.  123456
B.  579
C. 编译错误
D. 运行时抛出异常
[单项选择] class Sock2 {   String color;   public boolean equals(Object o) {   return color.equals(((Sock2)o).color);   } }   class TestSocks {   public static void main(String [] args) {   Sock2 s1 = new Sock2(); s1.color = "blue";   Sock2 s2 = new Sock2(); s2.color = "blue";   if (s1.equals(s2)) System.out.print("equals ");   if (s1 == s2) System.out.print("== ");   }   }   结果为:()      
A. ==
B. equals
C. equals ==
D. 无结果输出
[单项选择] Given:   11. String test = "This is a test";   12. String[] tokens = test.split("/s");   13. System.out.println(tokens.length);   What is the result?()
A.  An exception is thrown at runtime.
B.  1
C.  4
D.  Compilation fails.
E.  0
[单项选择] public String makinStrings() {  String s = “Fred”;  s = s + “47”;  s = s.substring(2, 5);  s = s.toUpperCase();  return s.toString();  }  How many String objects will be created when this method is invoked?() 
A.  1
B.  2
C.  3
D.  4
E.  5
F.  6
[单项选择] public static void test(String str) { int check = 4;  if (check = str.length()) {  System.out.print(str.charAt(check -= 1) +“, “);  } else {  System.out.print(str.charAt(0) + “, “);  }  }  and the invocation:  test(”four”);  test(”tee”); test(”to”);  What is the result?() 
A.  r, t, t,
B.  r, e, o,
C.  Compilation fails.
D.  An exception is thrown at runtime.
[单项选择] int index = 1;  String [] test = new String[3];  String foo = test[index];     What is the result?()  
A.  Foo has the value “”
B.  Foo has the value null
C.  An exception is thrown
D.  The code will not compile
[多项选择] class Sock {  String size;  String color;  public boolean equals(Object o) {  Sock s = (Sock) o;  return color.equals(s.color);   }  // insert code here  }  哪两个满足 hashCode 的约定?()
A. public int hashCode() { return 343; }
B. public int hashCode() { return size.hashCode (); }
C. public int hashCode() { return color.hashCode (); }
D. public int hashCode() { return (int) (Math.random() * 1000);
[单项选择] class Guy { String greet() { return "hi "; } }  class Cowboy extends Guy { String greet() { return "howdy "; } }  class Wrangler extends Cowboy { String greet() { return "ouch! "; } }  class Greetings2 {  public static void main(String [] args) {  Guy g = new Wrangler();  Guy g2 = new Cowboy();  Wrangler w2 = new Wrangler();  System.out.print(g.greet()+g2.greet()+w2.greet());  }  }  结果是什么?() 
A. hi hi ouch!
B. hi howdy ouch!
C. ouch! howdy ouch!
D. 编译失败
[多项选择] String s= "hello";     String t = "hello";  char c[] = {’h’,’e’,’l’,’l’,’o’} ;     Which return true?()   
A.  s.equals(t);
B.  t.equals(c);
C.  s==t;
D.  t.equals(new String("hello"));
E.  t==c;
[单项选择] 现有:  class Guy {String greet()    {return "hi";  }  }  class Cowboy extends Guy  (  String greet()    (  return "howdy  ¨;    )  )  class Surfer extends Guy  (String greet()    (return "dude! ";)) class Greetings  {  public static void main (String  []  args)    {  Guy  []  guys =  ( new Guy(), new Cowboy(), new Surfer()  );  for (Guy g:  guys) System.out.print (g.greet()};  }  }  结果为:() 
A.  hi howdy dude!
B. 运行时异常被抛出。
C. 第7行出现一个错误,编译失败。
D. 第8行出现一个错误,编译失败。
[多项选择] Given: String value = getServletContext().getInitParameter("foo"); in an HttpServlet and a web applicationdeployment descriptor that contains: foo frodo Which two are true?()
A. The foo initialization parameter CANNOT be set programmatically.
B. Compilation fails because getInitParameter returns type Object.
C. The foo initialization parameter is NOT a servlet initialization parameter.
D. Compilation fails because ServletContext does NOT have a getInitParameter method.
E. The foo parameter must be defined within the  element of the deployment descriptor.
[单项选择] 11. String test = “Test A. Test B. Test C.”;  12. // insert code here  13. String[] result = test.split(regex);  Which regular expression inserted at line 12 will correctly split test into “Test A,” “Test B,” and “Test C”?()
A.  String regex = “”;
B.  String regex = “ “;
C.  String regex = “.*“.
D.  String regex = “//s”
E.  String regex = “//.//s*”;
F.  String regex = “//w[ /.] +“;
[单项选择] 11. String test = “This is a test”;  12. String[] tokens = test.split(”/s”);  13. System.out.println(tokens.length);  What is the result?() 
A.  0
B.  1
C.  4
D.  Compilation fails.
E.  An exception is thrown at runtime.
[多项选择] 35. String #name = “Jane Doe”;  36. int$age=24;  37. Double_height = 123.5;  38. double~temp = 37.5;  Which two are true?()
A.  Line 35 will not compile.
B.  Line 36 will not compile.
C.  Line 37 will not compile.
D.  Line 38 will not compile.
[单项选择] Given: 11.String test = "Test A. Test B. Test C."; 12.// insert code here 13.String[] result = test.split(regex); Which regular expression, inserted at line 12,correctly splits test into "Test A","Test B",and "Test C"?()
A. String regex = "";
B. String regex = " ";
C. String regex = ".*";
D. String regex = "//s";
E. String regex = "//.//s*";
[多项选择] Given: 35.String #name = "Jane Doe"; 36.int $age = 24; 37.Double _height = 123.5; 38.double ~temp = 37.5; Which two statements are true?()
A. Line 35 will not compile.
B. Line 36 will not compile.
C. Line 37 will not compile.
D. Line 38 will not compile.
[单项选择] Given: 11.String test = "This is a test"; 12.String[] tokens = test.split("/s"); 13.System.out.println(tokens.length); What is the result?()
A. 0
B. 1
C. 4
D. Compilation fails.
[单项选择] 现有:  String s="write a line to a file";     w.print(s+"/n");      哪一个是对的?() 
A. w即可以是PrintWriter类型,也可以足BufferedWriter类型。
B. w即不可以是PrintWriter类型,也不可以足BufferedWriter类型。
C. w可以是BufferedWriter类型,但不可以是PrintWriter类型。
D.  w以是PrintWriter类型,但不可以是BufferedWriter类型。
[填空题] 3. string foo = “ABCDE”;  4. foo.substring(3);   5. foo.concat(“XYZ”);   6.   Type the value of foo at line 6.()
[填空题] 5. String foo = “base”;  6. foo.substring(0,3);  7. foo.concat(“ket”)  8.     Type the value of foo at line 8.()

我来回答:

购买搜题卡查看答案
[会员特权] 开通VIP, 查看 全部题目答案
[会员特权] 享免全部广告特权
推荐91天
¥36.8
¥80元
31天
¥20.8
¥40元
365天
¥88.8
¥188元
请选择支付方式
  • 微信支付
  • 支付宝支付
点击支付即表示同意并接受了《购买须知》
立即支付 系统将自动为您注册账号
请使用微信扫码支付

订单号:

截图扫码使用小程序[完全免费查看答案]
请不要关闭本页面,支付完成后请点击【支付完成】按钮
恭喜您,购买搜题卡成功
重要提示:请拍照或截图保存账号密码!
我要搜题网官网:https://www.woyaosouti.com
我已记住账号密码