Intelligent Java Common API Knowledge test

Source: Internet
Author: User
Tags dateformat true true

Common API Sections

A total of 40 choice questions, 2.5 points per question. 31-40 is a multi-choice, multi-choice error is all wrong, all the right to full score.

    1. The function of the GetBytes () method in the String class is () C

A) turn an integer into a string

b) Turn the string into a character array

c) Turn the string into a byte array

D) Gets the number of characters in the string

    1. Using indexof (' a ') and LastIndexOf (' a ') for the string "ABABCDABCDEFG", the Run result is () B

a)

b) 0,6

c) 0,0

D) 1,6

    1. What is the result of running the following program () a

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

    1. The correct argument for a string is () D

A) string is the base data type

b) String values are stored in the stack memory

c) can be changed after initialization of string value

d) The string value will not be changed once it is initialized

    1. The String Class Charat () method acts as () a

A) returns the character at the specified index

b) Returns the string specified by the index

c) Returns the index of the specified character

d) Returns the index of the specified string

    1. The way to convert a string to a character array is () B

A) toString ()

b) ToCharArray ()

c) toUpperCase ()

d) toLowerCase ()

    1. StringBuffer the initial capacity of the string buffer is the number of characters () d

A) 10 x

b) 12 x

c) 14 x

d) 16 X

    1. Appends a string to the string buffer, using the method () C

A) Length ()

b) Delete ()

c) Append ()

d) toString ()

    1. About StringBuffer and StringBuilder saying right is () C

A) different methods of StringBuffer and StringBuilder

b) StringBuffer and StringBuilder are thread-safe

c) StringBuffer is thread-safe, StringBuilder is not thread-safe

D) StringBuffer is not thread-safe, StringBuilder is thread-safe

10. Which of the following programs runs the result of 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 ') operation result is () D

A) 2

b) 5

c)-1

D) 7

12. The way to cut a string is () C

A) indexOf ()

b) substring ()

c) Split ()

d) Trim ()

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

a) replace ()

b) toString ()

c) substr ()

d) substring ()

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

String str = "ABCDEFG";

Str.substring (0,2);

System.out.println (str);

a) AB

b) ABC

c) ABCDEFG

D) Subscript out-of-bounds exception occurred

15. The following program operation results are () 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 following program operation 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. About the static method in the integer class The parseint () method is correct () B

A) convert decimals to integers

b) Convert a number format string to an integer

c) the parseint () method never throws an exception

d) turn a single character into an integer

18. Turn the decimal number 100 into a binary number using which method () A

A) tobinarystring ()

b) tohexstring ()

c) Intvalue ()

d) tooctalstring ()

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

Integer x = 3;

x = x + 3;

SYSTEM.OUT.PRINTLN (x);

A) compilation failed

b) X3

C) 6

D) Null

The role of System.getproperties () is () a

A) Gets the properties of the current operating system

b) Get the properties of the current JVM

c) Gets the operating system properties indicated by the specified key

d) Gets the properties of the JVM indicated by the specified key

21. The method by which the absolute value can be obtained is () D

A) Math.ceil ()

b) Math.floor ()

c) Math.pow ()

d) Math.Abs ()

Math.random () is correct () c

A) returns an indeterminate integer

b) return 0 or 1

c) Returns a random number of double types greater than or equal to 0.0 less than 1.0

d) Returns a random number of int of type greater than or equal to 0.0 less than 1.0

Math.ceil (-12.5) operation result is () D

A)-13

b)-11

C)-12

D)-12.0

Math.floor (15.6) operation result is () a

A) 15.0

b) 15

c) 16.0

d) 16.6

25. In the random class, the method that can generate a random number of positive integers within 100 is () C

A) nextdouble ()

b) Nextfloat ()

c) nextint (100)

d) Nextint ()

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

A) getseconds ()

b) GetTime ()

c) GetDay ()

d) getDate ()

27. Which method can turn the millisecond value into A Date object () A

A) Construction methods in the date class

b) The SetTime method in the date class

c) The GetTime method in the date class

d) The Format method in the SimpleDateFormat class

The parse () method in the DateFormat class describes the correct () C

A) turn the millisecond value into a Date object

b) Format Date Object

c) Convert the string to a Date object

d) Convert date objects to strings

Day_of_week in the Calendar class can get to () C

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 following program operation results are () 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 True

b) False true

c) True Flase

D) False false

The append () method in the StringBuffer class describes the correct () AC

A) Append character data to the buffer

b) Remove the string from the buffer

c) Append () method return value type is StringBuffer type

d) Append () method return value type is string type

The split () method in the String class describes the correct () AC

A) cutting strings

b) returns a new string

c) Returns a new array of strings

D) This method has no return value

33. The following statement is correct () ACD

A) string buffers are designed to improve the operational efficiency of strings

b) StringBuilder is thread-safe

c) StringBuffer is thread-safe

D) the valueof () method of the string class can turn any type into a string

34. The IndexOf argument about the String class is incorrect () 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 specified substring in this string

35. All of the following descriptions of the Equals () method in the String class are correct () ABC

a) equals () is overridden by the Equals () method in the object class

b) equals () compares the contents of a string, case-sensitive

equalsIgnoreCase(String anotherString)
Compare this to String another String , regardless of case.

c) The return value of the Equals () method is a Boolean type

D) The above statements are not correct

36. About Math.PI The right thing to say is () AB

A) Static constants

b) Be final modified

c) Math.PI each run results in a different

D) The above statements are correct

37. The method by which the current date millisecond value can be obtained is () AB

a) Dated = new Date (); D.gettime ();

b) System.currenttimemillis ();

c) gettime () in the calendar;

d) gettime in DateFormat ()

38. With regard to null and "" It is correct to say () ABD

A) null is a constant

b) "" is a String object

c) NULL can call method

D) "" Method can be called

The substring () method in the String class describes the correct () AB

A) Gets a portion of the string

b) return a new string

c) return a new string array

D) This method has no return value

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

A) Only one string object was created

b) created two objects, one is the new String () object, and the other is an "ABC" Object

c) str.equals ("abc"); will return true

d) str.equals ("abc"); will return false

Intelligent Java Common API Knowledge test

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.