Home > Java > JavaInterview questions > 9 common multiple-choice questions in Java written exams

9 common multiple-choice questions in Java written exams

(*-*)浩
Release: 2019-11-12 15:16:28
Original
7061 people have browsed it

9 common multiple-choice questions in Java written exams

1. Regarding Java compilation, which of the following is correct () (choose one)

A.A Java program will generate machine after compilation code

B. After the Java program is compiled, it will produce byte code

C. After the Java program is compiled, it will produce DLL

D. None of the above is correct

Answer: B

Analysis: Java is an interpreted language, and the compiled language is bytecode; therefore A is incorrect, C is the C/C language compiled dynamic link library file: .DLL; The correct answer is B

2. The following statements are correct () (select one)

The construtor in A.class cannot be omitted

B.construtor has the same name as the class, but the method cannot have the same name as the class

C.construtor is executed when an object is new

D.A class can only define one construtor

Answer: C

Analysis: A: If the construtor in the class is omitted, the system will provide a parameter-less construct by default

B: The method name can be the same as the class The name has the same name, but it does not comply with the naming convention

D: N multiple construtors can be defined in a class, and these construtors constitute the overloading of the constructor method

3. Modification of interfaces in Java The symbol can be () (select one)

A.private

B.protected

C.final

D.abstract

Answer: D

Analysis: The access modifier in the interface can only be public or default

All methods in the interface must implement the class Implementation, so you cannot use final

All methods in the interface are abstract by default, so the interface can be modified with abstract, but usually abstract can be omitted.

4. Given For the following code, the program will output () (select one)

class A {
    public A(){
        System.out.println("A");
    }
}
class B extends A{
    public B(){
        System.out.println("B");
    }
    public static void main(String[] args) {
        B b=new B();
    }
}
Copy after login

A. Cannot pass compilation

B. Pass compilation, output AB

C. Pass Compile and output B

D. Compile and output A

Answer: B

Analysis: Under the inheritance relationship, create a subclass object and execute the parent first The constructor method of the class, and then execute the constructor method of the subclass.

5. Which of the following statements about the use of keywords is incorrect () (select one)

A.abstract cannot be used to modify the same class in parallel with final

B.abstract class can have private members

C.abstract method must be in abstract class

D.static method can handle non-static attributes

Answer: D

Analysis: Because the static method is completed first when loading the class, earlier than the constructor method, at this time, the non-static properties and methods have not yet completed initialization and cannot be called.

6. Which of the following statements about memory recycling are correct () (choose one)

A. The programmer must create a thread to release memory

B. The memory recycling program is responsible for releasing useless memory

C. The memory recycling program allows programmers to directly release memory

D. The memory recycling program can release memory objects at a specified time

Answer: B

Analysis: A. Programmers do not need to create threads to release memory.

C. Programmers are not allowed to release memory directly .

D. Garbage collection does not necessarily occur at what time.

7. Select a reasonable identifier () (choose two)

A._sysl_111

B.2 mail

C.$change

D.class

Answer: AC

Analysis: The command specifications of identifiers can contain letters, numbers, underscores, $, cannot start with numbers, and cannot be Java keywords

8. The following statement is correct () (Multiple choice)

A.java.lang.Cloneable is a class

B.java.langRunnable is an interface

C.Double object is in java.lang In the package

D.Double a=1.0 is the correct java statement

Double a=1.0 is the correct java statement

Analysis: java.lang.Cloneable is the interface

9. The following description of inheritance is incorrect ()

A Inheritance in Java allows a subclass to inherit multiple parent classes

B. The parent class is more general, and the subclass is more specific

C. Inheritance in Java is transitive

D. When the subclass is instantiated, the parent class will be called recursively Construction method

Answer: A

Analysis: Java is single inheritance, and a class can only inherit one parent class.

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

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template