Java Foundation Pen Questions

Source: Internet
Author: User
Tags true true

Java Foundation strengthening

knowledge points to be examined : junit Test

1. in the following note, which is the method for defining a Junit unit Test () (difficulty A)

A,@Test

B,@Ignor

C,@Before

D,@After

knowledge points to be examined : Foundation-Enhanced generics

2. Which of the following is not a generic advantage ()(difficulty A)

A, generics have no effect on the security of Java programs

B. reduce the cast operation

C, converting the runtime's type conversion exception to compile errors

D, can simplify the traversal with the generic collection, simplifies the code

knowledge points to be examined : base-Enhanced enumeration

3. which one of the following is used to declare an enumeration class ()(difficulty a)

A,Enum

B,enumeration

C,enum

D,ENUM

Examining Knowledge points : Basic strengthening generics

7. The following definition of generics is correct () (difficulty B)

A, generics can be defined on a class, generics defined on a class can be used directly on non- static members

B, generics can be defined on a class, generics defined on a class can be used on all members

C, generics can be defined on a method, generics defined on a method can only be used within a method

D, generics can be defined on a method, and the defined location must be before the method return value .

examine the Knowledge points : The Foundation strengthens the enumeration

8. The following about enumeration is correct () (difficulty B)

A, an enumeration can have an abstract method

B, all enumerated items are public static final decorated by default

C, the constructor method in the enumeration is private by default and can be overloaded

D. Cannot have member properties in enumerations

examine the Knowledge points : The Foundation strengthens the enhanced for Loop

9. Use the enhanced for Loop to manipulate which of the following types () (difficulty B )

A,java.util.List collection

B, Array

C, all implemented the iterable interface

D,java.lang.String

Examining Knowledge points : Foundation strengthening variable parameters

Example public void Add (int ... a) calling the add method is correct () (Difficulty B)

A,Add (ON)

B,Add (1,2,3,4)

C,Add (New int[]{1,2,3,4})

D,Add ()

Examining Knowledge points : Basic strengthening generics

One . Example

List<number> list=new arraylist<number> ();

called AddAll method can be added with the () (difficulty C)

A,list<integer> a=new arraylist<integer> ();

B,set<integer> b=new hashset<integer> ();

C,list<double> c=new arraylist<double> ();

D,list<string> d=new arraylist<string> ();

examine the Knowledge point : The Foundation strengthens the reflection

12.java obtained in Class object in a way that has () (difficulty B)

A. get through class name . class

B, through the object . GetClass () get

C. get through Class.forName

D, through the object . Class Get

examine the Knowledge point : The Foundation strengthens the reflection

which of the following methods can get a class of constructors () (difficulty B)

A,getconstructor (Class<?>.... parametertypes)

B,getdeclaredconstructor (Class<?>.... parametertypes)

C,getdeclaredconstructors ()

D,getconstructors ();

examine the Knowledge point : The Foundation strengthens the reflection

which of the following methods can get a member variable () of a class ( difficulty B )

A,getdeclaredfields ()

B,Getdeclaredfield (String name)

C,GetField (String name)

D, the above are not

examine the Knowledge point : The Foundation strengthens the reflection

The following method can get the member method of a class () (difficulty B)

A,getdeclaredmethods ()

B,getdeclaredmethod (String name)

C,GetMethod (String name)

D, the above are not

examine the Knowledge point : The Foundation strengthens the reflection

Which of the following methods can be used to access private members through reflection? (difficulty B)

A,GetMethod ();

b,setaccessible (Boolean B)

C,getdeclaredconstructors ()

D,getconstructors ();

examine the Knowledge point : The Foundation strengthens the packing class

Example ( version JDK1.5 and above )

Integer in1=new integer (100);

Integer in2=new integer (100);

Integer in3=100;

Integer in4=100;

System.out.println (in1==in2);

System.out.println (in2==in3);

System.out.println (IN3==IN4);

The result of the program execution is () (difficulty C)

A,false false

B,false False True

C,false True True

D, the above are not

examine the points of knowledge : base-Enhanced reflection

get The execution entry of a class Test by reflection main method

Method Main=test.class. Getdeclaredmethod ("main", String[].class);

Execution Main method below the correct is () (difficulty C)

A,main.invoke (null, new Object[]{new string[]{"abc"}});

B,main.invoke (null,new string[]{"abc"})

C,main.invoke (NULL, "ABC")

D,main.invoke (null, (Object) (New string[]{"abc"})

examine the Knowledge point : The Foundation strengthens the reflection

A static method called in a class (Test) by Reflection Show () the correct is ()

Method show = ... .. ; (Difficulty C )

A,show.invoke (null);

B,show.invoke (Test)

C,Show.invoke (Test.class.newInstance ())

D, the above are not

examine the Knowledge point : The Foundation strengthens the reflection

Which of the following methods can call the default construction method by reflection ( difficulty C)

A, class name . Class.newinstance ();

B, class name . Class.getconstructor (). newinstance ()

C,new class name ();

D, the above are not

Java Foundation Pen Questions

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.