Home>Article>Java> Common multiple choice questions in Java written test

Common multiple choice questions in Java written test

(*-*)浩
(*-*)浩 Original
2019-11-18 16:46:01 3835browse

Common multiple choice questions in Java written test

1. Known expression int m[] = {0,1,2,3,4,5,6}; The value of the following expression and the array The lengths are equal ()

A m.length()

B. m.length

C. m.length() 1

D. m.length 1

Answer: B

Analysis: The length of the array is .length

2. Below Are those claims legitimate? ()

A long l = 4990

B. int i = 4L

C. float f = 1.1

D. double d = 34.4

Answer: AD

Analysis: B int belongs to integer type and should be int=4 C should be float f=1.1f

3. Select the correct java expression () from the following options

A int k=new String("aa")

B. String str = String("bb" )

C. char c=74;

D. long j=8888;

Answer: CD

Analysis: A requires forced type conversion B String str =new String("bb")

4. The output result of the following code is

System.out.println(""+("12"=="12"&&"12".equals("12"))); (“12”==”12”&&”12”.equals(“12”)) “12”==”12”&&”12”.equals(“12”)

true

false

5. Which of the following operators contain short-circuit operation mechanism? Please select: ()

A &

B. &&

#C. |

D. ||

Answer: BD

Analysis: A C is logic and calculation

6. Which of the following functions is the key to public void example(){....} load function? ()

A private void example(int m){...}

B. public int example(){...}

C. public void example2(){...}

D. public int example(int m.float f){...}

Answer: AD

Analysis: BC defines a new function

7. Given a certain java program fragment, after the program is run, the output result of j is ()

int i=1; Int j=i++; If((j>++j)&&(i++==j)){j+=i:} System.out.println(j);

A 1

B. 2

C. 3

D. 4

Answer: B

Analysis: i is quoted first. i is added first and then quoted

8. In java, no matter what the test condition is, the following () loop will be executed at least once.

A for

B. do...while

C. while

D. while...do

Answer: B

Analysis: ACD does not necessarily cycle

9. Print result:

package cn.wuliaokankan; public class smaillT{ public static void main(String args[]){ smaillT t=new smaillT(); int b = t.get(); System.out.println(b); } public int get() { try { return 1; }finally{ return 2; } }

Output result:

2

10. Indicate the running result of the following program

int i=9; switch (i) { default: System.out.println("default"); case 0: System.out.println("zero"); break; case 1: System.out.println("one"); break; case 2: System.out.println("two"); break; }

Print result:

zero

The above is the detailed content of Common multiple choice questions in Java written test. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn