SCJP程序员认证考试

单选题33. Date d = new Date(0);  34. String ds = “December 15, 2004”;  35. // insert code here  36. try {  37. d = df.parse(ds);  38. }  39. catch(ParseException e) {  40. System.out.println(”Unable to parse “+ ds);  41. }  42. // insert code here too  Which

题目
单选题
33. Date d = new Date(0);  34. String ds = “December 15, 2004”;  35. // insert code here  36. try {  37. d = df.parse(ds);  38. }  39. catch(ParseException e) {  40. System.out.println(”Unable to parse “+ ds);  41. }  42. // insert code here too  Which will create the appropriate DateFormat object and add a day to the Date object?()
A

 35. DateFormat df= DateFormat.getDateFormat(); 42. d.setTime( (60 * 60 * 24) +d.getTime());

B

 35. DateFormat df= DateFormat.getDateJnstance(); 42. d.setTime( (1000 * 60 * 60 * 24) + d.getTime());

C

 35. DateFormat df= DateFormat.getDateFormat(); 42. d.setLocalTime( (1000*60*60*24) + d.getLocalTime());

D

 35. DateFormat df= DateFormat.getDateJnstance(); 42. d.setLocalTime( (60 * 60 * 24) + d.getLocalTime());

如果没有搜索结果,请直接 联系老师 获取答案。
如果没有搜索结果,请直接 联系老师 获取答案。
相似问题和答案

第1题:

33.Dated=newDate(0);34.Stringds=December15,2004”;35.//insertcodehere36.try{37.d=df.parse(ds);38.}39.catch(ParseExceptione){40.System.out.println(”Unabletoparse+ds);41.}42.//insertcodeheretooWhichwillcreatetheappropriateDateFormatobjectandaddadaytotheDateobject?()

A.35.DateFormatdf=DateFormat.getDateFormat();42.d.setTime((60*60*24)+d.getTime());

B.35.DateFormatdf=DateFormat.getDateJnstance();42.d.setTime((1000*60*60*24)+d.getTime());

C.35.DateFormatdf=DateFormat.getDateFormat();42.d.setLocalTime((1000*60*60*24)+d.getLocalTime());

D.35.DateFormatdf=DateFormat.getDateJnstance();42.d.setLocalTime((60*60*24)+d.getLocalTime());


参考答案:B

第2题:

public class TestString3 {  public static void main(String[] args) {  // insert code here  System.out.println(s);  }  }  Which two code fragments, inserted independently at line 3, generate the output 4247?()

  • A、 String s = “123456789”; s = (s-”123”).replace(1,3,”24”) - “89”;
  • B、 StringBuffer s = new StringBuffer(”123456789”); s.delete(0,3).replace( 1,3, “24”).delete(4,6);
  • C、 StringBuffer s = new StringBuffer(”123456789”); s.substring(3,6).delete( 1 ,3).insert(1, “24”);
  • D、 StringBuilder s = new StringBuilder(”123456789”); s.substring(3,6).delete( 1 ,2).insert( 1, “24”);
  • E、 StringBuilder s = new StringBuilder(”123456789”); s.delete(0,3).delete( 1 ,3).delete(2,5).insert( 1, “24”);

正确答案:B,E

第3题:

GivenavaidDateFormatobjectnameddf,andWhatupdatesd’svaluewiththedaterepresentedbyds?()

A.18.d=df.parse(ds);

B.18.d=df.getDate(ds);

C.18.try{19.d=df.parse(ds);20.}catch(ParseExceptione){}

D.18.try{19.d=df.getDate(ds);20.}catch(ParseExceptione){}


参考答案:C

第4题:

31. // some code here  32. try {  33. // some code here  34. } catch (SomeException se) {  35. // some code here  36. } finally {  37. // some code here  38. }  Under which three circumstances will the code on line 37 be executed?()

  • A、 The instance gets garbage collected.
  • B、 The code on line 33 throws an exception.
  • C、 The code on line 35 throws an exception.
  • D、 The code on line 31 throws an exception.
  • E、 The code on line 33 executes successfully.

正确答案:B,C,E

第5题:

33. try {  34. // some code here  35. } catch (NullPointerException e1) {  36. System.out.print(”a”);  37. } catch (RuntimeException e2) {  38. System.out.print(”b”);  39. } finally {  40. System.out.print(”c”);  41. }  What is the result if a NullPointerException occurs on line 34?() 

  • A、 c
  • B、 a
  • C、 ab
  • D、 ac
  • E、 bc
  • F、 abc

正确答案:D

第6题:

GivenavalidDateFormatobjectnameddf,and16.Dated=newDate(0L);17.Stringds="December15,2004";18.//insertcodehereWhatupdatesd’svaluewiththedaterepresentedbyds?()

A.18.d=df.parse(ds);

B.18.d=df.getDate(ds);

C.18.try{19.d=df.parse(ds);20.}catch(ParseExceptione){};

D.18.try{19.d=df.getDate(ds);20.}catch(ParseExceptione){};


参考答案:C

第7题:

class One {  void foo() {}  }  class Two extends One {   //insert method here  }  Which three methods, inserted individually at line 14, will correctly complete class Two?()

  • A、 int foo() { /* more code here */ }
  • B、 void foo() { /* more code here */ }
  • C、 public void foo() { /* more code here */ }
  • D、 private void foo() { /* more code here */ }
  • E、 protected void foo() { /* more code here */ }

正确答案:B,C,E

第8题:

Dated=newDate(0L);17.Stringds=December15,2004”;18.//insertcodehereWhatupdatesd?svaluewiththedaterepresentedbyds?()

A.18.d=df.parse(ds);

B.18.d=df.getDate(ds);

C.18.try{19.d=df.parse(ds); 20.}catch(ParseExceptione){};

D.18.try{ 19.d=df.getDate(ds); 20.}catch(ParseExceptione){};


参考答案:C

第9题:

16. Date d = new Date(0L);  17. String ds = “December 15, 2004”;  18. // insert code here  What updates d‟s value with the date represented by ds?()

  • A、 18. d = df.parse(ds);
  • B、 18. d = df.getDate(ds);
  • C、 18. try {     19. d = df.parse(ds);      20. } catch(ParseException e) { };
  • D、 18. try {      19. d = df.getDate(ds);       20. } catch(ParseException e) { };

正确答案:C

第10题:

33. Date d = new Date(0);  34. String ds = “December 15, 2004”;  35. // insert code here  36. try {  37. d = df.parse(ds);  38. }  39. catch(ParseException e) {  40. System.out.println(”Unable to parse “+ ds);  41. }  42. // insert code here too  Which will create the appropriate DateFormat object and add a day to the Date object?() 

  • A、 35. DateFormat df= DateFormat.getDateFormat(); 42. d.setTime( (60 * 60 * 24) +d.getTime());
  • B、 35. DateFormat df= DateFormat.getDateJnstance(); 42. d.setTime( (1000 * 60 * 60 * 24) + d.getTime());
  • C、 35. DateFormat df= DateFormat.getDateFormat(); 42. d.setLocalTime( (1000*60*60*24) + d.getLocalTime());
  • D、 35. DateFormat df= DateFormat.getDateJnstance(); 42. d.setLocalTime( (60 * 60 * 24) + d.getLocalTime());

正确答案:B

更多相关问题