Possible error in ocp-816 (1/62)

Post Reply
ocpjp11user
Posts: 6
Joined: Mon Jan 13, 2020 10:05 pm
Contact:

Possible error in ocp-816 (1/62)

Post by ocpjp11user »

Hi guys)

This is foundation test question 62:
foundation test - 62.png
foundation test - 62.png (25.51 KiB) Viewed 13160 times
Fifth option regarding the use of

Code: Select all

@SuppressWarnings("all")
is misleading.
Explanation said that all is not allowed, although if you run
javac -X
and go to -Xlint section you will see the full list of possible values.

Code: Select all

 -Xlint:<key>(,<key>)*
        Warnings to enable or disable, separated by comma.
        Precede a key by - to disable the specified warning.
        Supported keys are:
          all                  Enable all warnings
          auxiliaryclass       Warn about an auxiliary class that is hidden in a source file, and is used from other files.
          cast                 Warn about use of unnecessary casts.
          classfile            Warn about issues related to classfile contents.
          deprecation          Warn about use of deprecated items.
          dep-ann              Warn about items marked as deprecated in JavaDoc but not using the @Deprecated annotation.
          divzero              Warn about division by constant integer 0.
          empty                Warn about empty statement after if.
          exports              Warn about issues regarding module exports.
          fallthrough          Warn about falling through from one case of a switch statement to the next.
          finally              Warn about finally clauses that do not terminate normally.
          module               Warn about module system related issues.
          opens                Warn about issues regarding module opens.
          options              Warn about issues relating to use of command line options.
          overloads            Warn about issues regarding method overloads.
          overrides            Warn about issues regarding method overrides.
          path                 Warn about invalid path elements on the command line.
          processing           Warn about issues regarding annotation processing.
          rawtypes             Warn about use of raw types.
          removal              Warn about use of API that has been marked for removal.
          requires-automatic   Warn about use of automatic modules in the requires clauses.
          requires-transitive-automatic Warn about automatic modules in requires transitive.
          serial               Warn about Serializable classes that do not provide a serial version ID. 
                             Also warn about access to non-public members from a serializable element.
          static               Warn about accessing a static member using an instance.
          try                  Warn about issues relating to use of try blocks (i.e. try-with-resources).
          unchecked            Warn about unchecked operations.
          varargs              Warn about potentially unsafe vararg methods
          preview              Warn about use of preview language features
          none                 Disable all warnings
As you see all is real value to disable all warnings.

admin
Site Admin
Posts: 10036
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: Possible error in ocp-816 (1/62)

Post by admin »

You are right. The explanation has been updated as follows:
Although you can pass any string value to the SuppressWarnings annotation (unrecognized values are ignored), the Java specification mandates only three values - unchecked, deprecation, and removal. Different compilers and IDEs may support other values in addition to these three.

There is no rule that says the value "all" has to supress all warnings (although a compiler or an IDE may do that upon seeing this value.)
If you like our products and services, please help us by posting your review here.

ocpjp11user
Posts: 6
Joined: Mon Jan 13, 2020 10:05 pm
Contact:

Re: Possible error in ocp-816 (1/62)

Post by ocpjp11user »

Thanks)
Where did you get the list of these 3 (unchecked, deprecation, and removal)?
I haven't find anything, but google stackoverflow come to conclusion that 3 strandard suppresswarning value are (unchecked, deprecated, serial)

admin
Site Admin
Posts: 10036
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: Possible error in ocp-816 (1/62)

Post by admin »

Please go through section 9.6.4.5 @SuppressWarnings of JLS 11.
If you like our products and services, please help us by posting your review here.

Post Reply

Who is online

Users browsing this forum: No registered users and 19 guests