中文字幕在线一区二区在线,久久久精品免费观看国产,无码日日模日日碰夜夜爽,天堂av在线最新版在线,日韩美精品无码一本二本三本,麻豆精品三级国产国语,精品无码AⅤ片,国产区在线观看视频

      最新java題庫及答案

      時間:2024-06-12 17:29:44 JAVA認證 我要投稿

      2016最新java題庫及答案

        Java是由Sun Microsystems公司推出的Java面向對象程序設計語言(以下簡稱Java語言)和Java平臺的總稱,為幫助大家更好學習java設計語言,yjbys小編為大家分享最新java考試題庫如下:

        1)Which code fragment would correctly identify the number of arguments passed via the command line to a Java application, excluding the name of the class that is being invoked? A)int count=0; while (!(args[count].equals(""))) count ++;

        B)int count = args.length - 1;

        C)int count = args.length;

        D)int count = 0; while (args[count] != null) count ++;

        2)Which class do you use to write data into a text file? 2) _______

        A)File B) System C)Scanner D) PrintWriter

        3)Analyze the following code.

        class Test {

        public static void main(String[ ] args) {

        String s;

        System.out.println("s is " + s);

        }

        }

        A)The program compiles and runs fine.

        B)The program has a runtime error because s is not initialized, but it is referenced in the println statement.

        C)The program has a compilation error because s is not initialized, but it is referenced in the println statement.

        D)The program has a runtime error because s is null in the println statement.

        4)How can you get the word "abc" in the main method from the following call?

        java Test "+" 3 "abc" 2 4) _______

        A)args[2] B) args[1] C) args[3] D) args[0]

        5)What is the output of the following code?

        public class Test {

        public static void main(String[ ] args) {

        String s1 = new String("Welcome to Java!");

        String s2 = new String("Welcome to Java!");

        if (s1.equals(s2))

        System.out.println("s1 and s2 have the same contents");

        else

        System.out.println("s1 and s2 have different contents");

        }

        }

        A)s1 and s2 have the same contents B)s1 and s2 have different contents

        6)What is the output of the following code?

        public class Test {

        public static void main(String[ ] args) {

        String s1 = "Welcome to Java!";

        String s2 = "Welcome to Java!";

        if (s1 == s2)

        System.out.println("s1 and s2 reference to the same String object");

        else

        System.out.println("s1 and s2 reference to different String objects");

        }

        }

        A)s1 and s2 reference to the same String object B)s1 and s2 reference to different String objects

        7)Which of the following is true? (Choose all that apply.) 7) _______

        A)You can add characters into a string buffer.

        B)The capacity of a string buffer can be automatically adjusted.

        C)You can reverse the characters in a string buffer.

        D)You can delete characters into a string buffer.

        8)To check if a string s contains the suffix "Java", you may write (Choose all that apply.)

        A)if (s.charAt(s.length() - 4) == 'J' && s.charAt(s.length() - 3) == 'a' && s.charAt(s.length() - 2) == 'v' && s.charAt(s.length() - 1) == 'a') ...

        B)if (s.substring(s.length() - 5).equals("Java")) ...

        C)if (s.lastIndexOf("Java") >= 0) ...

        D)if (s.endsWith("Java")) ...

        E)if (s.substring(s.length() - 4).equals("Java")) ...

        9)What is displayed by the following code?

        public static void main(String[ ] args) throws Exception {

        String[ ] tokens = "Welcome to Java".split("o");

        for (int i = 0; i < tokens.length; i++) {

        System.out.print(tokens[i] + " ");

        }

        }

        A)Welc me to Java B) Welcome to Java

        C)Welcome t Java D) Welc me t Java

        10)Which class do you use to read data into a text file? 10) ______

        A)Scanner B) System C)PrintWriter D) File

        1)C 2)D 3)C 4)A 5)A 6)A 7)A, B, C, D 8)A, D, E 9)D 10)A

        11)Suppose you enter 34.3 57.8 789, then press the ENTER key. Analyze the following code.

        Scanner scanner = new Scanner(System.in);

        int value = scanner.nextDouble();

        int doubleValue = scanner.nextInt();

        String line = scanner.nextLine();

        A)After the last statement is executed, intValue is 34.

        B)After the last statement is executed, line contains characters '7', '8', '9', '\n'.

        C)After the last statement is executed, line contains characters '7', '8', '9'.

        D)The program has a runtime error because 34.3 is not an integer.

        12)Which of the following statements are true? 12) ______

        A)If a file (e.g., c:\temp.txt) does not exist, new File("c:\\temp.txt") creates a new file named c:\temp.txt.

        B)If a directory (e.g., c:\liang) does not exist, new File("c:\liang") creates a new directory named c:\liang.

        C)If a file (e.g., c:\temp.txt) does not exist, new File("c:\\temp.txt") returns null.

        D)If a directory (e.g., c:\liang) does not exist, new File("c:\liang") returns null.

        E)None of the above.

        13)Which of following is not a correct method in Character? (Choose all that apply.) 13) ______

        A)isLetter(char) B)isDigit() C)isLetterOrDigit(char) D)toLowerCase(char) E)toUpperCase()

        14)Which class contains the method for checking whether a file exists? 14) ______

        A)System B) Scanner C)File D) PrintWriter

        15)Which of the following statements creates an instance of File on Window for the file c:\t.txt?

        A)new File("c:\txt.txt") B) new File("c:\\txt.txt")

        C)new File("c://txt.txt") D) new File("c:/txt.txt")

        16)________ returns the last character in a StringBuilder variable named strBuf? 16) ______

        A)StringBuilder.charAt(strBuf.capacity() - 1)

        B)strBuf.charAt(strBuf.capacity() - 1)

        C)StringBuilder.charAt(strBuf.length() - 1)

        D)strBuf.charAt(strBuf.length() - 1)

        17)Assume StringBuilder strBuf is "ABCCEFC", after invoking ________, strBuf contains "ABTTEFT". 17) ______

        A)strBuf.replace("C", "T")

        B)strBuf.replace("CC", "TT")

        C)strBuf.replace('C', 'T')

        D)strBuf.replace('C', "TT")

        E)strBuf.replace(2, 7, "TTEFT")

        18)Which of the following returns the path separator character? 18) ______

        A)File.separatorChar

        B)File.pathSeparatorChar

        C)File.pathSeparator

        D)File.separator

        E)None of the above.

        19)Analyze the following code.

        class Test {

        public static void main(String[ ] args) {

        StringBuilder strBuf = new StringBuilder(4);

        strBuf.append("ABCDE");

        System.out.println("What's strBuf.charAt(5)? " + strBuf.charAt(5));

        }

        }

        A)The program has a runtime error because the length of the string in the buffer is 5 after "ABCDE" is appended into the buffer. Therefore, strBuf.charAt(5) is out of range.

        B)The program compiles and runs fine.

        C)The program has a runtime error because because the buffer's capacity is 4, but five characters "ABCDE" are appended into the buffer.

        D)The program has a compilation error because you cannot specify initial capacity in the StringBuilder constructor.

        20)Suppose Character x = new Character('a'), ________ returns true. (Choose all that apply.) A)x.equals(new Character('a'))

        B)x.compareToIgnoreCase('A')

        C)x.equals('a')

        D)x.equals("a")

        E)x.equalsIgnoreCase('A')

        11)B 12)E 13)B, E 14)C 15)B 16)D 17)E 18)B 19)A 20)A, C

        21)The following program displays ________.

        public class Test {

        public static void main(String[ ] args) {

        String s = "Java";

        StringBuilder buffer = new StringBuilder(s);

        change(s);

        System.out.println(s);

        }

        private static void change(String s) {

        s = s + " and HTML";

        }

        }

        A)Java and HTML B) and HTML C)nothing is displayed D) Java

        22)To check if a string s contains the prefix "Java", you may write (Choose all that apply.)

        A)if (s.indexOf("Java") == 0) ...

        B)if (s.startsWith("Java")) ...

        C)if (s.substring(0, 4).equals("Java")) ...

        D)if (s.charAt(0) == 'J' && s.charAt(1) == 'a' && s.charAt(2) == 'v' && s.charAt(3) == 'a') ...

        23)Which of the following statements is preferred to create a string "Welcome to Java"?

        A)String s; s = new String("Welcome to Java");

        B)String s = "Welcome to Java";

        C)String s; s = "Welcome to Java";

        D)String s = new String("Welcome to Java");

        24)Which method can be used to write data? 24) ______

        A)exist B) print C) close D) rename

        25)Which method can be used to create an output object for file temp.txt? (Choose all that apply.)

        A)new PrintWriter("temp.txt")

        B)new PrintWriter(new File("temp.txt"))

        C)new PrintWriter(File("temp.txt"))

        D)new PrintWriter(temp.txt)

        26)Assume StringBuilder strBuf is "ABCDEFG", after invoking ________, strBuf contains "AEFG". 26) ______

        A)strBuf.delete(1, 3) B) strBuf.delete(2, 4) C)strBuf.delete(0, 3) D) strBuf.delete(1, 4)

        27)Suppose you enter 34.3, the ENTER key, 57.8, the ENTER key, 789, the ENTER key. Analyze the following code.

        Scanner scanner = new Scanner(System.in);

        int value = scanner.nextDouble();

        int doubleValue = scanner.nextInt();

        String line = scanner.nextLine();

        A)After the last statement is executed, intValue is 34.

        B)After the last statement is executed, line contains characters '7 ', '8 ', '9'.

        C)After the last statement is executed, line contains character '\n '.

        D)The program has a runtime error because 34.3 is not an integer.

        E)After the last statement is executed, line contains characters '7', '8', '9', '\n'.

        28)Which of the following is the correct statement to return a string from an array a of characters?

        A)toString(a) B) convertToString(a) C)new String(a) D) String.toString(a)

        29)What is the return value of "SELECT".substring(0, 5)? 29) ______

        A)"SELECT" B) "SELE" C)"SELEC" D) "ELECT"

        30)Suppose s1 and s2 are two strings. What is the result of the following code?

        s1.equals(s2) == s2.equals(s1)

        A)true B) false

        21)D 22)A, B, C, D 23)B 24)B 25)A, B 26)D 27)C 28)C 29)C 30)A

        31)Which method can be used to create an input object for file temp.txt? 31) ______

        A)new Scanner("temp.txt")

        B)new Scanner(temp.txt)

        C)new Scanner(File("temp.txt"))

        D)new Scanner(new File("temp.txt"))

        32)Assume s is "ABCABC", the method ________ returns an array of characters. 32) ______

        A)String.toCharArray()

        B)String.toChars()

        C)s.toCharArray()

        D)s.toChars()

        E)toChars(s)

        33)Which correctly creates an array of five empty Strings? 33) ______

        A)String[ ] a = new String [5];

        B)String[ ] a = {"", "", "", "", ""};

        C)String[ ] a = new String [5]; for (int i = 0; i < 5; a[i++] = null);

        D)String[5] a;

        34)Assume StringBuilder strBuf is "ABCDEFG", after invoking ________, strBuf contains "ABCRRRRDEFG". 34) ______

        A)strBuf.insert(1, "RRRR") B) strBuf.insert(3, "RRRR")

        C)strBuf.insert(2, "RRRR") D) strBuf.insert(4, "RRRR")

        35)Suppose s1 and s2 are two strings. Which of the following statements or expressions are incorrect? (Choose all that apply.) 35) ______

        A)s1.charAt(0) = '5'

        B)String s = new String("new string");

        C)String s3 = s1 + s2

        D)s1 >= s2

        E)int i = s1.length

        36)Suppose s1 and s2 are two strings. Which of the following statements or expressions is incorrect? (Choose all that apply.) 36) ______

        A)char c = s1.charAt(s1.length());

        B)boolean b = s1.compareTo(s2);

        C)char c = s1[0];

        D)String s3 = s1 - s2;

        37)What are the reasons to create an instance of the File class? (Choose all that apply.) 37) ______

        A)To delete the file.

        B)To read/write data from/to a file

        C)To rename the file.

        D)To obtain the properties of the file such as whether the file can be read, written, or is hidden.

        E)To determine whether the file exists.

        38)Identify the problems in the following code.

        public class Test {

        public static void main(String argv[ ]) {

        System.out.println("argv.length is " + argv.length);

        }

        }

        A)The program has a compile error because String argv[ ] is wrong and it should be replaced by String[ ] args.

        B)If you run this program without passing any arguments, the program would display argv.length is 0.

        C)If you run this program without passing any arguments, the program would have a runtime error because argv is null.

        D)The program has a compile error because String args[ ] is wrong and it should be replaced by String args[ ].

        39)What is the return value of "SELECT".substring(4, 4)? 39) ______

        A)T B) an empty string C)C D) E

        40)Assume s is " abc ", the method ________ returns a new string "abc". 40) ______

        A)trim(s) B) String.trim(s) C)s.trim(s) D) s.trim()

        31)D 32)C 33)B 34)B 35)A, D, E 36)A, B, C, D 37)A, C, D, E 38)B 39)B 40)D

        41)"abc".compareTo("aba") returns ________. 41) ______

        A)1 B) 0 C) -1 D) -2 E) 2

        42)What is the output of the following code?

        public class Test {

        public static void main(String[ ] args) {

        String s1 = new String("Welcome to Java");

        String s2 = s1;

        s1 += "and Welcome to HTML";

        if (s1 == s2)

        System.out.println("s1 and s2 reference to the same String object");

        else

        System.out.println("s1 and s2 reference to different String objects");

        }

        }

        A)s1 and s2 reference to the same String object

        B)s1 and s2 reference to different String objects

        43)Which method can be used to read a whole line from the file? 43) ______

        A)nextDouble B) nextLine C)next D) nextInt

        44)Which of the following is the correct header of the main method? (Choose all that apply.) A)static void main(String[ ] args)

        B)public static void main(String args[ ])

        C)public static void main(String x[ ])

        D)public static void main(String[ ] x)

        E)public static void main(String[ ] args)

        45)What is displayed by the following statement?

        System.out.println("Java is neat".replaceAll("is", "AAA")); 45) ______

        A)JavaAAA neat B) Java AAAneat C)Java AAA neat D) JavaAAAneat

        46)"AbA".compareToIgnoreCase("abC") returns ________. 46) ______

        A)2 B) -1 C) -2 D) 0 E) 1

        47)The StringBuilder methods ________ not only change the contents of a string buffer, but also returns a reference to the string buffer. (Choose all that apply.) 47) ______

        A)insert B)replace C)delete D)append E)reverse

        48)________ returns true. (Choose all that apply.) 48) ______

        A)"peter".equalsIgnoreCase("Peter")

        B)"peter".compareToIgnoreCase("peter")

        C)"peter".compareToIgnoreCase("Peter")

        D)"peter".equals("peter")

        E)"peter".equalsIgnoreCase("peter")

        49)The following program displays ________.

        public class Test {

        public static void main(String[ ] args) {

        String s = "Java";

        StringBuilder buffer = new StringBuilder(s);

        change(buffer);

        System.out.println(buffer);

        }

        private static void change(StringBuilder buffer) {

        buffer.append(" and HTML");

        }

        }

        A)Java B) Java and HTML C)nothing is displayed D) and HTML

        50)Suppose s is a string with the value "java". What will be assigned to x if you execute the following code?

        char x = s.charAt(4);

        A)'a' B)'v'

        C)Nothing will be assigned to x, because the execution causes the runtime error StringIndexOutofBoundsException.

        41)E 42)B 43)B 44)B, C, D, E 45)C 46)C 47)A, B, C, D, E 48)A, D, E 49)B 50)C

      【最新java題庫及答案】相關文章:

      2016最新java考試題庫及答案07-23

      2016年java面向對象編程題庫及答案10-24

      最新中國詩詞大會題庫及答案04-23

      2016最新Java認證筆試題及答案01-21

      2016年最新JAVA編程題及答案08-08

      托福口語題庫及答案11-01

      java習題及答案10-25

      最新中興Java語言筆試真題及答案10-09

      2024年最新java面試題及答案11-01

      安全生產知識題庫及答案09-20

      主站蜘蛛池模板: 开心五月婷婷伊人久久| 一区二区三区国产高潮| 国产精品亚洲专区无码不卡| 日本久久精品免费播放| 在线偷窥制服另类| 亚洲AⅤ男人的天堂在线观看| 中文字幕亚洲乱亚洲乱妇| 中文无码制服丝袜人妻AV| 亚洲av人片在线观看调教| 亚洲五月婷婷久久综合| 凤阳县| 中文字幕人妻系列一区尤物视频| 亚洲一区精品中文字幕| 国产大陆av一区二区三区| 国产精品成人无码a 无码| 一级少妇无遮掩内射免费| 国产最新视频在线不卡| 美腿丝袜一区二区三区| 磴口县| 不卡免费av在线高清| 孟津县| 巫山县| 炉霍县| 库车县| 宣汉县| 汤原县| 综合国产av一区二区三区| 亚洲女同系列高清在线观看 | 亚洲av午夜福利精品一区二区| 国产成人av综合色| 色噜噜狠狠色综合欧洲| 喷潮出白浆视频在线观看| 国产一区二区三区免费精品| 亚洲a∨好看av高清在线观看| 91精品国产91热久久p| 丝袜人妻无码中文字幕综合网| 日本少妇爽的大叫高潮了| 国产一区亚洲欧美成人| www.尤物视频.com| 亚洲av国产大片在线观看| 人妻一区二区三区蜜桃|