Chuanzhi Java common API knowledge test and Java API knowledge

Source: Internet
Author: User

Chuanzhi Java common API knowledge test and Java API knowledge
Common APIs

A total of 40 multiple choice questions, each question 2.5 points. 31-40 is a multi-choice question. If there is a wrong multiple-choice question, it is all wrong. The full right is the perfect score.

 

A) Convert the integer into a string.

B) convert the string into a character array.

C) convert the string into a byte array.

D) obtain the number of characters in the string.

 

A) 1, 1

B) 0, 6

C) 0, 0

D) 1,6

 

Public static void main (String [] args ){

String s1 = "abc ";

String s2 = "xyz ";

Show (s1, s2 );

System. out. println (s1 + "-----" + s2 );

}

Static void show (String s1, String s2 ){

S1 = s2 + s1 + "Q ";

S2 = "W" + s1;

}

A) abc ----- xyz

B) xyzabcQ ----- xyzWabc

C) xyzabcQ ---- xyzabcQWabc

D) xyzQ ---- Wabc

 

A) string is the basic data type.

B) The string value is stored in the stack memory.

C) The string value can be changed after initialization.

D) The string value will not be changed once initialized.

 

A) returns the characters at the specified index.

B) returns the string from the specified index.

C) returns the index of the specified character.

D) returns the index of the specified string.

 

A) toString ()

B) toCharArray ()

C) toUpperCase ()

D) toLowerCase ()

 

A) 10

B) 12

C) 14

D) 16

 

A) length ()

B) delete ()

C) append ()

D) toString ()

 

A) The StringBuffer and StringBuilder methods are different.

B) Both StringBuffer and StringBuilder are thread-safe.

C) StringBuffer is thread-safe, and StringBuilder is NOT thread-safe.

D) StringBuffer is NOT thread-safe, and StringBuilder is thread-safe.

 

10. Which of the following programs returns true () C

A) System. out. println ("abc". equals ("Abc "));

B) System. out. println ("". equals (null ));

C) System. out. println ("abc" = "AB" + "c ");

D) System. out. println ("". equalsIgnoreCase (null ));

 

11. The following code "ibelieve". lastIndexOf ('E') runs as () D

A) 2

B) 5

C)-1

D) 7

 

12. The method to cut the string is () C

A) indexOf ()

B) substring ()

C) split ()

D) trim ()

 

13. The method for intercepting a string is () D.

A) replace ()

B) toString ()

C) substr ()

D) substring ()

 

14. The result of the following program running is () C

String str = "abcdefg ";

Str. substring (0, 2 );

System. out. println (str );

A) AB

B) abc

C) abcdefg

D) An error occurred while exceeding the subscript limit.

 

15. The running result of the following program is () C

Public static void main (String [] args ){

StringBuffer sb = new StringBuffer ();

Sb. append ("qq"). append ("ww ");

Show (sb, "ss ");

System. out. println (sb. length ());

}

Static void show (StringBuffer sb, String str ){

Sb. append (str );

}

A) 4

B) 2

C) 6

D) 0

 

16. The result of the program running below is () D

String str1 = "1", str2 = "2 ";

If (str1 = str2)

System. out. println ("ABC ");

Else if (str1 <str2)

System. out. println ("DEF ");

Else

System. out. println ("GHJ ");

 

A) ABC

B) DEF

C) GHJ

D) Compilation failed

 

17. Which of the following statements about the parseInt () method of the static method in the Integer class is true? () B

A) converts decimals to integers.

B) convert a numeric string to an integer.

C) The parseInt () method will never throw an exception

D) convert a single character to an integer

 

18. Which method () A is used to convert the decimal number 100 to the binary number?

A) toBinaryString ()

B) toHexString ()

C) intValue ()

D) toOctalString ()

 

19. The result of the following code is () C

Integer x = 3;

X = x + 3;

System. out. println (x );

A) compilation failed.

B) x3

C) 6

D) Null

 

20. The function of System. getProperties () is ().

A) Get the properties of the current operating system

B) obtain the attributes of the current JVM.

C) obtain the operating system attributes of the specified key indication

D) Get the JVM attribute of the specified key indication

 

21. The way to obtain the absolute value is () D.

A) Math. ceil ()

B) Math. floor ()

C) Math. pow ()

D) Math. abs ()

 

22. Which of the following statements about Math. random () is true? () c

A) returns an uncertain integer.

B) returns 0 or 1.

C) return a random number of double types, which is greater than or equal to 0.0 and less than 1.0

D) return a random number of int types, which is greater than or equal to 0.0 and less than 1.0

 

23. The running result of Math. ceil (-12.5) is () D

A)-13

B)-11

C)-12

D)-12.0.

 

24. The running result of Math. floor (15.6) is ().

(A) 15.0

B) 15

(C) 16.0

(D) 16.6

 

25. In the Random class, the method for generating Random numbers of positive integers less than 100 is () C

A) nextDouble ()

B) nextFloat ()

C) nextInt (100)

D) nextInt ()

 

26. In the Date class, which method can return the millisecond value () B of the current Date object?

A) getSeconds ()

B) getTime ()

C) getDay ()

D) getDate ()

 

27. Which method can convert the millisecond value to the date object ()?

A) Construction Method in the Date class

B) The setTime method in the Date class

C) The getTime method in the Date class

D) format method in SimpleDateFormat class

 

 

28. Which of the parse () methods in the DateFormat class are correctly described is () C

A) Convert the millisecond value to a date object.

B) format the date object.

C) convert a string to a date object.

D) convert the date object to a string

 

29. You can obtain () C from Day_OF_WEEK in the Calendar class.

A) one day of the year

B) One day of the month

C) One day of the week

D) the last day of the month

 

30. The running result of the following program is () d

String s1 = "abc ";

String s2 = new String ("abc ");

System. out. println (s1 = s2 );

String s3 = "how are you ";

String s4 = "you ";

String s5 = "OK ";

System. out. println (s3 = (s4 + s5 ))

A) true

B) false true

C) true flase

D) false

 

31. Which of the following statements about the append () method in the StringBuffer class is true? () AC

A) append character data to the buffer zone

B) Delete the strings in the buffer.

C) the return value type of the append () method is StringBuffer.

D) the return value type of the append () method is String.

 

32. Which of the following statements about the split () method in the String class is true? () AC

A) Cut string

B) returns a new string.

C) returns a new string array.

D) This method does not return values.

 

33. Which of the following statements is true? () ACD

A) The string buffer is used to improve the efficiency of string operations.

B) StringBuilder is thread-safe.

C) StringBuffer is thread-safe.

D) the valueOf () method of the String class can convert any type into a String.

 

34. Which of the following statements about indexOf the String class is false? () CD

A) returns the index of the first occurrence of the specified character in the string.

B) returns the index of the first occurrence of the specified substring in the string.

C) returns the index of the last occurrence of the specified character in the string.

D) returns the index of the last occurrence of the substring.

 

35. Which of the following statements about the equals () method in the String class is true? () ABC

A) The equals () method overwrites the equals () method in the Object class.

B) equals () compares the content in the string, case sensitive

equalsIgnoreCase(String anotherString)
Set thisStringWith anotherStringComparison, not case sensitive.

C) the return value of the equals () method is boolean.

D) the above statements are incorrect.

 

36. Which of the following statements about Math. PI is true? () AB

A) Static Constants

B) modified by final

C) Math. PI has different running results.

D) the above statements are correct.

 

37. The method for obtaining the millisecond value of the current date is () AB

A) Dated = new Date (); d. getTime ();

B) System. currentTimeMillis ();

C) getTime () in the Calendar ();

D) getTime () in DateFormat ()

 

38. Which of the following statements about null and "" is true? () ABD

A) null is a constant.

B) "" is a string object.

C) null can call methods.

D) "" can call Methods

 

39. Which of the following statements about the substring () method in the String class is true? () AB

A) obtain part of the string

B) returns a new string.

C) returns a new string array.

D) This method does not return values.

 

40. The following code is about String str = new String ("abc"); the correct description is () BC.

A) Only one string object is created.

B) two objects are created. One is the new String () object and the other is the "abc" object.

C) str. equals ("abc"); returns true

D) str. equals ("abc"); false is returned.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.