I study every day to get a Java Bronze.

I asked a question because I couldn't understand the contents of the problem collection.

Which is valid for the definition of the Market class constructor? Please select two.

A. public final Market () {}

B. private static Market () {}

C. public Market (String item) {}

D.private void Market () {}

E. public Market () {}

Constructor definition is

Qualifier class name (argument list)


If i am not convinced

・ Why is final, static, void after the modifier?

・ Isn't there a return value for void, so it is treated as a method? Is it related to this question?

・ What about static and final other than void

Thanks for your understanding.

Addition: Problem answer

The answer is C, E

The explanation is correct because it satisfies the conditions of the constructor.

It is described as


A, B, D
Does not meet constructor conditions
・ The return type has been declared
・ Cannot specify modifier

There is


  • Answer # 1


    Why is final, static, void after the modifier?

    Does not enter.
    Because they are in, they are wrong as constructor definitions.

    Which is the correct addition?
    Standard arithmetic operators include addition (+), subtraction (-), multiplication (*), and division (/).

    A. x + y
    B. x plus y
    C. x plus y

    Of course, the correct answer is A, but what you are saying is
    Why is the letter "plus" or "plus" after x?
    It is like saying.
    The answer is "does not enter".

  • Answer # 2

    First, in Java, the constructor distinguishes it from other methods byno return value. Therefore, at the moment when the return value is written, it is treated as a "just method" and is no longer a constructor. (In some languages, the method of making a method with a specific name a constructor is used. ).

    And as long as you create an instance and initialize it, astaticconstructor "doesn't make sense. And since the constructor works in a different framework than normal overrides,finalalso makes no sense.

    … can be reasoned, but as a result there may be cases where meaningless syntax remains, and ultimatelyhow the grammar isThere is no meaning.

    Related questions of StackOverflow

  • Answer # 3

    The reverse of that question is which one is wrong as a constructor, but I don't agree with the wrong one I wonder if there is no way to do it.
    Or is it that you don't understand the method description?