Question: Consider the following partial code for some Java class: public class Person { public static final int maxPeople = 1 0 ; public Person (
Consider the following partial code for some Java class:
public class Person public static final int maxPeople ; public Person rest of class continues here...
Assume the remainder of the class is defined correctly. What, if anything, is the biggest problem with this portion of code?
Question Answer
a
The variable maxPeople should not be initialised until a constructor is called.
b
There is nothing that will cause a syntax error in the code, however, convention dictates that the maxPeople variable name should be capitalised with underscores, rather than in camel case.
c
A field cannot be both static and final.
d
There is nothing visibly wrong with the code, syntactically or otherwise.
e
The access modifier for maxPeople should be private, not public.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
