Java Constants QuizS2C Home « Java Constants Quiz

Java Objects & Classes Quiz 14

The quiz below tests your knowledge of the material learnt in Objects & Classes - Lesson 14 - Java Constants.

Question 1 : What do Java constants apply to?
- Java constants apply to a class
Question 2 : We use static and which keyword to define a Java constant?
- We use <code>static</code> and the <code>final</code> keyword to define a Java constant.
Question 3 : You must always assign a value to a static variable marked as final before you use it or the compiler complains?
- You MUST always assign a value to a static variable marked as <code>final</code> before you use it or the compiler complains.
Question 4 : Which runs first after a class has loaded?
- Static initializer blocks.
Question 5 : Can we initiailize Java constants in a method?
- Java constants can only be initialized when they are defined or in a static initializer block.
Question 6 : When defining a Java constant which comes first?
- It doesn't matter in which order these keywords appear although the official documentation gives a preferred ordering of static final.
Question 7 : A Java constant can never change once it has been assigned a value?
- A Java constant CAN NEVER change once it has been assigned a value.
Quiz Progress Bar Please select an answer


What's Next?

The next quiz on Java Objects & Classes is all about enumerations.