1.run start
public static void Main (String args[]) { thread t = new Thread () {public void run () { pong ()} }; T.run (); System.out.print ("ping"); } static void Pong () { System.out.print ("Pong"); }
A pingpong B pongping C pingpong and pongping may not output D
Answer: B
Parsing: Here is the difference between the start () and run () methods in the thread class. Start () is used to start a thread, and when the Start method is called, the system will open a new thread and call the run () method to perform the task, and the separate call to run () is the same as calling the normal method, and has lost the thread's characteristics. So when starting a thread, be sure to use Start () instead of run ().
2.
. Which stream class belongs to the character-oriented input stream ()
A bufferedwriter B fileinputstream C objectinputstream D inputstreamreader
Answer: D
Parsing: Java IO operations have both byte-oriented (byte) and character-oriented (Character) methods.
Byte-oriented operations operate on binary data in 8-bit units, and the data is not converted, and these classes are subclasses of InputStream and OutputStream.
Character-oriented operations manipulate data in characters, convert binary data to characters at read time, and convert characters to binary data when writing, which are subclasses of reader and writer.
Summary: The InputStream (input)/outputstream (output) is the suffix of the byte stream;
The word stream is the suffix of reader (input)/writer (output).
Extension: Java Flow class diagram structure, at a glance, to solve most of the choice problems:
3. Can I create an object without a constructor function ()
A Yes B no
Answer: A
Parsing: Java creates objects in several ways (important):
(1) Create objects with the new statement, which is the most common way to create objects.
(2) using the reflection means, call the Java.lang.Class or Java.lang.reflect.Constructor class newinstance () instance method.
(3) Call the object's clone () method.
(4) The ReadObject () method of the Java.io.ObjectInputStream object is invoked by means of deserialization.
(1) and (2) will explicitly call the constructor, (3) is a photocopy of an existing object in memory, so the constructor is not called, (4) is the object that restores the class from the file, and the constructor is not called.
4.
17. Which of the following is the symmetric encryption algorithm ()
A DES B AES C DSA D RSA
Answer: AB
Parsing: The commonly used symmetric encryption algorithms are: DES, 3DES, RC2, RC4, AES
The commonly used asymmetric encryption algorithms are: RSA, DSA, ECC
Cryptographic algorithms using a one-way hash function: MD5, SHA
5.
Class Helloa {public Helloa () { System.out.println ("Helloa"); } {System.out.println ("I ' M A class");} static {System.out.println ("static A");}} public class Hellob extends Helloa {public Hellob () { System.out.println ("Hellob"); } {System.out.println ("I ' M B class");} static {System.out.println ("static B");} public static void Main (string[] args) {new Hellob (); }}
Answer:
Static Astatic BI ' m A classhelloai ' m B classhellob
Parsing: To be honest I think this is a good question, to examine the static statement blocks, construct the block of statements (that is, the one with the curly braces), and the execution order of the constructors.
Object Initialization Order: (1) After the class is loaded, the static modified statement is executed from top to bottom (from parent to subclass), (2) when the static statement is executed, then the main method is executed, and (3) If the statement new has its own object, the construction code block is executed from top to bottom, Constructors (both of which can be said to be bound together).
The code below is slightly modified to illustrate the situation more clearly:
Class Helloa {public Helloa () { System.out.println ("Helloa"); } {System.out.println ("I ' M A class");} static {System.out.println ("static A");}} public class Hellob extends Helloa {public Hellob () { System.out.println ("Hellob"); } {System.out.println ("I ' M B class");} static {System.out.println ("static B");} public static void Main (string[] args) { System.out.println ("-------main start-------"); New Hellob (); New Hellob (); SYSTEM.OUT.PRINTLN ("-------main end-------");} }
At this point the output is:
Static Astatic b-------main start-------I ' m a classhelloai ' m b Classhellobi ' m a classhelloai ' m b classhellob-------main en D-------
Java face question