Declaration and Access Control in Java - Quiz

  • A The program has a compilation error because it does not have a main method.
  • B The program will compile, but we cannot create an object of Circle with a specified radius. The object will always have radius 0.
  • C The program has a compilation error because we cannot assign radius to radius.
  • D The program does not compile because Circle does not have a default constructor.
  • A Compile error at line 1 (static x must be only accessed inside static methods)
  • B Compile error at line 2 (constructors can't be static)
  • C Compile error at line 3 (static methods can't invoke this)
  • D Compile error at line 4 (invalid argument type for method main )
  • A Declare the method with the keyword public.
  • B Declare the method with the keyword private.
  • C Declare the method with the keyword protected.
  • D Do not declare the method with any accessibility modifiers.