1. Which of the following methods are executable Java program entry methods (A,B,D).
A) public static void main (string[] hello)
b) public static void Main (String world[])
c) static public String main (string[] args)//Return value type must be empty
d) static public void Main (string[] test)
2. Which of the following are the reference types in Java (a,b,c,d).
A) array of basic data types
b) interface
c) string
d) Array of reference data types
3. Which of the following methods can create a new object (A,B,C,D).
A) Construction method
b) Reflection
c) Cloning
D) deserialization
4. The following description of polymorphism in the Java language is correct (a,b,c,d).
A) rewriting is a means of implementing run-time polymorphism
b) Overloading is a means of implementing compile-time polymorphism
c) encapsulation, inheritance and polymorphism are important pillars of object-oriented programming
D) polymorphism refers to the same behavior in different manifestations
5. The following is an explanation of what is wrong with abstract classes and interfaces (A,b,d).
A) Abstract classes can only include abstract methods, must write the abstract keyword //abstract class does not necessarily include only abstract methods, the argument is too absolute
b) The method in the interface can only be abstract, but cannot write the abstract keyword //abstract keyword can be omitted, cannot be said to be unable to write
c) The method in the interface can only be public
D) The method in the interface can only be public //The access modifier of a method in an interface is not necessarily public
6. What happens when you compile and run the following program (c).
public class MyThread extends Thread {
public static void Main (String args[]) {
Thread t = new MyThread ();
T.start ();
}
public void Start () {
System.out.println ("Execute Start Method");
}
public void Run () {
System.out.println ("Execute Run Method");
}
}
A) Compilation error
b) Run exception
c) Output "execute Start Method"
d) Output "execute Run Method"
7. What happens when you compile and run the following program (d).
public class Program {
public static void Main (String args[]) {
Program P = new program ();
P.foo ();
}
public void Foo () {
int i;
System.out.println (i);
}
}
A) by compiling and outputting 0
b) Generate compilation errors
c) by compiling and outputting null
d) compile but run exception //In the constructor method foo, the int i member variable does not have an initial value assigned, so it is reported nullpointerexception at run time.
8. To implement the cloning of an object, you can implement which of the following interfaces (A,c).
A) cloneable
b) Runnable
c) Serializable
D) Comparator
9. The following code outputs the result (d).
public class Test {
public static String output = "";
public static void foo (int i) {
try {
if (i = = 1) {
throw new Exception ();
}
Output + = "1";
} catch (Exception e) {
Output + = "2";
Return
} finally {
Output + = "3";
}
Output + = "4";
}
public static void Main (String args[]) {
Foo (0);
Foo (1);
SYSTEM.OUT.PRINTLN (output);
}
}
A) 1342
b) 123
c) 134234
D) 13423
10. To traverse the elements in a list object, the following statement is correct (a, B).
list<string> list = new arraylist<> ();
List.add ("a");
list<string> list = new arraylist<> ();
List.add ("a");
A) while (It.hasnext ())
System.out.println (It.next ());
b) for (int i = 0; i < list.size (); i++)
System.out.println (List.get (i));
c) while (List.hasnext ())
System.out.println (List.next ());
d) while (List.hasnext ())
System.out.println (List.next ());
11. The following code for obtaining the correct class object is (A,b,c,d).
A) Class.forName ("Java.util.Date")
b) String.class
c) Int.class
d) Int[].class;
12. The following statement about garbage collection is correct (a,b,c,d).
A) garbage collection is a background thread
b) Programmers cannot interfere with garbage collection
c) Garbage collection can only reclaim memory on the heap and cannot free external resources (such as open files)
d) Invoking the System class's GC method does not ensure that the garbage collector reclaims memory
Java Knowledge Point Display