Practice mode Java

How is the number of elements of a Java array named a obtained?

Correct answer B. a.length

Explanation

Every array has a public final field called length, so it is read without parentheses. The method form length() belongs to String, and size() belongs to collections such as ArrayList, which explains why the three are easily confused. Arrays have no count member, and the length cannot change after creation.

Report a problem

Answer checked How we write and check questions

Tip: press A, B, C or D to answer, and N for the next question.

Advertisement

Have a question about this answer?

Your email address will not be published. Required fields are marked *

Links and website addresses are not allowed in comments.