1Z0-811 · Question #46
Which method identifier is correct according to Java naming conventions?
The correct answer is D. Calculator. There appears to be an error in the provided answer key. The marked correct answer D (Calculator) is actually wrong for a method identifier - Calculator follows class naming conventions (PascalCase), not method conventions. The actual correct answer is B: calculateBill Here's…
Question
Options
- ABillCalculator
- BcalculateBill
- Ccalculatebill
- DCalculator
How the community answered
(39 responses)- A5% (2)
- B3% (1)
- C3% (1)
- D90% (35)
Explanation
There appears to be an error in the provided answer key. The marked correct answer D (Calculator) is actually wrong for a method identifier - Calculator follows class naming conventions (PascalCase), not method conventions.
The actual correct answer is B: calculateBill
Here's the proper explanation:
calculateBill is correct because Java method names must follow lowerCamelCase - beginning with a lowercase letter, with each subsequent word capitalized. This is a core Java convention enforced by style guides and widely expected in professional code.
- A (BillCalculator) - PascalCase (UpperCamelCase) is reserved for class and interface names, not methods.
- C (calculatebill) - All lowercase with no word separation is not a recognized Java convention; it reduces readability.
- D (Calculator) - Also PascalCase, making it a valid class name, not a method name.
Memory tip: Think of methods as actions that are humble - they start lowercase because they serve the class, while classes are proper nouns that start uppercase (like BillCalculator). If it starts lowercase and uses camelCase, it's a method.
I'd recommend flagging this to whoever provided the question - the answer key has D marked as correct, which contradicts standard Java naming conventions.
Topics
Community Discussion
No community discussion yet for this question.