Declaration and Access Control in Java - Quiz

  • AThis method is only accessible from inside the class itself and from inside all subclasses.
  • BIn a class, you cannot declare methods with a lower visibility than the visibility of the class in which it is defined.
  • CFrom within protected methods you do not have access to public methods.
  • DThis method is accessible from within the class itself and from within all classes defined in the same package as the class itself.
  • A Declare the method with the keyword public.
  • B Declare the method with the keyword private.
  • C Declare the method with the keyword protected.
  • DDo not declare the method with any accessibility modifiers.
  • 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.
  • A Only the Test class.
  • BAny class.
  • CAny class in com.mypackage package.
  • D Any class that extends Test.