Cattle Bus Error Set (8.9)

Error Set of Brush Titles for Niukou Passenger Network (8.9)

Time: August, 9 times a wrong set of brushing titles on Niuke.com.

Interfaces cannot extend (inherit) multiple interfaces. ()

Correct Answer: B Your Answer: A (Error)
A. Correct
B. Error
Answer Analysis:

java Classes are single-inherited. classB Extends classA
java Interfaces can inherit more than one. Interface3 Extends Interface0, Interface1, interface......
        The main reason class multiple inheritance is not allowed if A Simultaneous Inheritance B and C,and b and c There is also one D Method, A How do I decide which one to inherit?
        But there is no such problem with interfaces. It doesn't matter who inherits them all from abstract methods, so interfaces can inherit multiple interfaces.

The following statements about java instance variables, local variables, class variables, and final variables are incorrect?

Correct Answer: B Your Answer: C (Error)
A. Instance variables refer to variables defined in the class, that is, member variables, which have default values if not initialized.
B. Local variables refer to variables defined in a method that have default values if not initialized
C. Class variables refer to properties modified with static
A D.final variable is a variable modified with a final
Answer Analysis:

Local variables are variables in class methods and must be initialized. Local variables are allocated on the stack at runtime, which is large and has a short life cycle. It is an overhead if the virtual machine initializes each local variable, but it is not safe to use variables without initializing them to default values. For speed and security reasons, the solution is that the virtual machine is not initialized, but the writer must assign values to the variables before using them.

Which of the following classes are thread safe ()

Correct Answer: A D E Your Answer: A D (Error)
A.Vector
B.HashMap
C.ArrayList
D.StringBuffer
E.Properties
Answer Analysis:

A,Vector Equivalent to a thread-safe List
B,HashMap Is non-thread-safe, and its corresponding thread-safe class is HashTable
C,Arraylist Is non-thread-safe, and its corresponding thread-safe class is Vector
D,StringBuffer Thread-safe, equivalent to one thread-safe StringBuilder
E,Properties Implemented Map Interface, thread-safe

Which of the following descriptions are correct about some Java concepts: ()

Correct Answer: B F Your Answer: A B D F (Error)
A. All base classes for Java exceptions and errors are java.lang.Exception, including java.lang.RuntimeException
B. With a try...catch...finally statement, the statement part in finally is executed regardless of any exception that occurs
All data in C.java is an object
D.Java uses variables that are no longer referenced by garbage collection to ensure that the finallize method of the object is executed during garbage collection
E.Java is a cross-platform language, and programs written in any version of Java run on all Java platforms
Synchronization accessed by F.Java through synchronized, which acts on non-static member methods and synchronizes on static member methods with different goals
Answer Analysis:

A.Error ( Error)The base class is Throwable
C.Basic type is not an object
D.The garbage collector does not always work, it only works when memory resources are critical; Even if the garbage collector is working, finalize The method may not necessarily be executed either, because other threads in the program take precedence over execution. finalize()Priority of function threads. (This is the answer downstairs)
E.Low version JRE Cannot run high version JRE

With respect to the following code, the following statement is correct: ()

public class Test {
    private synchronized void a() {
    }
    private void b() {
        synchronized (this) {
        }
    }
    private synchronized static void c() {
    }
    private void d() {
        synchronized (Test.class) {
        }
    }
}

Correct Answer: A C Your Answer: B C (Error)
A. The same object, calling methods a and b, respectively, locks the same object
B. The same object, calling methods a and c, respectively, locks the same object
C. The same object, calling methods b and c, respectively, does not lock the same object
D. The same object, calling methods a, b, c respectively, does not lock the same object
Answer Analysis:

Synchronize code blocks ( synchronized(this),synchronized(Class Instance Object),Lock is parenthesis()Instance object in)
Synchronize non-static methods ( synchronized method),Lock is the instance object of the current object
 Get Class Lock
 Synchronize code blocks ( synchronized(class.class)),Lock is the smallest parenthesis () Class objects in Class Object)
Synchronize static methods ( synchronized static method),Locks are class objects of the current object ( Class Object)
summary
 When a thread accesses a synchronous block of code for an object, another thread can access the asynchronous block of code for that object
 If the same object is locked, one thread accesses the object's synchronization code block and the other accesses the object's synchronization code block.
If the same object is locked, one thread accesses the object's synchronization method and the other accesses the object's synchronization method.
If the same object is locked, one thread accesses the object's synchronization code block while the other accesses the object's synchronization method, and vice versa.
Locks of different objects of the same class do not interfere with each other
 Class locks, because they are also a special kind of object lock, behave the same as above, and since a class has only one object lock, using class locks on different objects of the same class will be synchronized
 Class locks and object locks do not interfere with each other

summary

No silicon steps can reach thousands of miles, no small streams can become rivers and seas.

Keywords: Java

Added by dahwan on Fri, 31 Dec 2021 12:17:21 +0200