Home
MCQs
Java MCQs
Naming conventions
Java MCQs

Java MCQs - Naming conventions

Naming conventions MCQs contains rules for writing naming styles for Fields, Methods, Classes, Interfaces, Packages and Constants

1. What is a naming convention in Java?

A. A rule for writing names of methods only

B. A rule for writing names of classes only

C. A rule for writing names of identifiers

Answer: C

2. Java naming convention is a suggestion only to follow

A. true

B. false

Answer: A

3. If you do not follow the naming conventions then you will fail to recognize Java identifiers

A. true

B. false

Answer: A

4. What the naming convention should be for Class in Java?

A. It should start with the uppercase letter.

B. It should be a noun such as Student, School, Book

C. Use appropriate words, instead of acronyms.

D. All of above

Answer: D

5. What the naming convention should be for Interfaces in Java?

A. It should start with the uppercase letter.

B. It should be an adjective such as Intelligent, Acceptable

C. Use appropriate words, instead of acronyms.

D. All of above

Answer: D

6. What the naming convention should be for Methods in Java?

A. It should start with lowercase letter.

B. It should be a verb such as show(), count(), describe()

C. If name contains many words then first word's letter start with lowercase only and other words will start with uppercase

D. All of above

Answer: D

7. What the naming convention should be for Variables in Java?

A. It should start with a lowercase letter such as id, name

B. It should not start with the special characters, And Avoid using one-character variables such as x, y, z.

C. If name have multiple names then start it with the lowercase letter followed by an uppercase letter such as firstName, lastName.

D. All of Above

Answer: D

8. What the naming convention should be for Packages in Java?

A. It should be a lowercase letter such as java, lang

B. If the name contains multiple words, it should be separated by dots (.) such as java.util, java.lang

C. All of above

Answer: C

9. What the naming convention should be for Constants in Java?

A. It should be in uppercase letters such as DAY, MONTH

B. If the name contains multiple words, it should be separated by an underscore(_) such as FINAL_DATE.

C. It may contain digits but not as the first letter

D. All of above

Answer: D

10. Which is the right naming convention for class in Java?

A. class EmployeeSalary

B. class employeeSalary

C. class Employee_Salary

D. All of above

Answer: A