Which of the following statements related to Java is FALSE?
2019
Which of the following statements related to Java is FALSE?
- A.
All class names should start with an upper-case letter.
- B.
It is not mandatory for the name of the program file to exactly match the class name.
- C.
All method names should start with a lower-case letter.
- D.
Java is a case-sensitive language.
Attempted by 235 students.
Show answer & explanation
Correct answer: B
Concept: In Java, source-file naming follows one governing rule — a .java file may contain at most one top-level public class or interface, and whenever such a public type exists, the file name must exactly match that type's name (including case), with a .java extension. If no top-level type in the file is public, the file name does not need to match any class name.
Applying this rule to each statement:
The statement that the file name is not mandatorily the same as the class name is phrased as an absolute rule with no exception. But matching IS mandatory whenever the class is declared public — for example, "public class Hello" must live in a file named Hello.java, or the compiler rejects it. Since the blanket claim ignores this mandatory case, it is false.
Class names starting with an upper-case letter is a widely followed style convention (PascalCase), not a compiler-enforced rule, so this statement holds true as a convention.
Method names starting with a lower-case letter (camelCase) is likewise a true style convention.
Java is indeed case-sensitive — myVar and MyVar are treated as distinct identifiers — so this statement is true.
Cross-check: of the four statements, three describe true facts or conventions about Java, while only the file-name-matching statement breaks down the moment a public class is involved. That confirms it as the false statement the question asks for.
A video solution is available for this question — log in and enroll to watch it.