Declaration and Access Control in Java - Quiz

  • ACompile error at line 1 (static x must be only accessed inside static methods)
  • BCompile error at line 3 (static methods can't make reference to non-static variables)
  • CCompile error at line 4 (invalid argument type for method main)
  • DCompile error at line 2 (must access x by writing Tester.x)
  • AAt Compile-time
  • BAt run-time
  • CDepends on the code
  • DNone of these
  • AThe program has a compilation error because it does not have a main method.
  • BThe program will compile, but we cannot create an object of Circle with a specified radius. The object will always have radius 0.
  • CThe program has a compilation error because we cannot assign radius to radius.
  • DThe program does not compile because Circle does not have a default constructor.
  • AThe will compile successfully and display 9 as output.
  • BThe program will lead to compilation error.
  • CThe program will lead to runtime error.
  • DThe program will compile successfully and display 10 as output.
  • A Only the Test class.
  • BAny class.
  • CAny class in com.mypackage package.
  • D Any class that extends Test.