Level 3: Multiple Choice (1)------Java Object-Oriented - Classes and Objects

  • 1. Which of the following statements about the construction method is incorrect ()

    A、

    The Java language stipulates that the constructor name must be the same as the class name

    B、

    The Java language stipulates that the constructor has no return value and is not declared with the void keyword

    C、

    Constructors cannot be overloaded

    D、

    Constructors can only be created with the new keyword

  • 2. The class Test is defined as follows:

     
       
    1. public class Test{
    2. public float method1(){
    3. System.out.println("方法1");
    4. return 1.5;
    5. }
    6. }

    第7行Which of the following methods is legal to insert into ()

    A、

    public float method1(){ System.out.println("方法2"); return 1.1; }

    B、

    public Test1(){ System.out.println("hello"); }

    C、

    public float method1( int a){ System.out.println("方法2"); return a+0.5; }

    D、

    public Test(){ System.out.println("hello"); }

Answer:

1.

Correct option: C

2.

Correct option: CD

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324132867&siteId=291194637