What is the output(static field)? : Questions « Modifiers « SCJP

class MyClass {
   static int referenceCount = 0;

  public MyClass() {

  protected void fly() {

  static int getRefCount() {
    return referenceCount;

class MySubclass extends MyClass {
  MySubclass() {


public class MainClass {
  public static void main(String args[]) {
    System.out.print("Before: " + MyClass.referenceCount);
    MySubclass florence = new MySubclass();
    System.out.println(" After: " + MyClass.referenceCount);

3.17.1.Which modifier should be used to control the persistent state?
3.17.2.Answer: persistent state and modifer
3.17.3.What is the output(extended class and static variable)?
3.17.4.Answer: extended class and static variable
3.17.5.What is the output(static field)?
3.17.6.Answer: static field variable
3.17.7.An abstract class may be instantiated (true/false)
3.17.8.Answer: abstract class and instantiation
3.17.9.An abstract class must contain at least one abstract method (true/false)
3.17.10.Answer: abstract class and abstract method
3.17.11.An abstract class must contain at least one abstract data field (true/false)
3.17.12.Answer: abstract class and abstract field
3.17.13.A top-level class may be declared as private(True/False).
3.17.14.Answer: top level class
3.17.15.A method may be declared as transient(True/False).
3.17.16.Answer: transient and method
3.17.17.A constructor may be declared as volatile.
3.17.18.Answer: volatile and method
3.17.19.What is the output of the following program(static field)?
3.17.20.Answer: static field
3.17.21.Local variables may be declared final(True/False).
3.17.22.Answer: local variable and final
3.17.23.Methods may be declared final(True/False).
3.17.24.Answer: final method
3.17.25.Constructors may not be declared private(True/False).
3.17.26.Answer: final and contructor
3.17.27.What is the output of the following program(static initializer)?
3.17.28.Answer: static initializer