Will the following code compile?

public class Person {
    public final String name;
    int age;
}
Explanation
The field with a final modifier must be initialized in the declaration or the value must be assigned to each constructor. Here, neither the one nor the other is not made so there will be a compilation error.

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback
Cosmo
Sign Up Now
or Subscribe for future quizzes