Page 1 of 1

About Question enthuware.ocpjp.v11.2.3064 :

Posted: Fri Dec 25, 2020 6:50 pm
by dimitrilc
Hello, for option B, it is not clear why x is typed to Object.

This explanation
Map has a method named keySet(), which returns Set<K>.
does not make a lot of sense here. I think it is clearer to say either
1:
Properties extends Hashtable<Object, Object> (note the concrete generic type of Object), so all references to K, V declared in Hashtable<K, V> become Object, Object. Just saying that Properties extends Hashtable is not enough; It should be Hashtable<Object, Object>.
2:
Properties overrides keySet() (and a bunch of other methods) to explicitly return Set<Object> in its source code

Code: Select all

    @Override
    public Set<Object> keySet() {
        return Collections.synchronizedSet(map.keySet(), this);
    }

Re: About Question enthuware.ocpjp.v11.2.3064 :

Posted: Sat Dec 26, 2020 6:18 am
by admin
It is explained in the explanation to the first option (just above the second one). Even so, the explanation has now been enhanced to make it clearer.
thank you for your feedback!

Re: About Question enthuware.ocpjp.v11.2.3064 :

Posted: Wed Feb 17, 2021 2:23 pm
by Deleted User 6318
How is this _ used as a keyword? What is purpose of that?

Re: About Question enthuware.ocpjp.v11.2.3064 :

Posted: Wed Feb 17, 2021 10:54 pm
by admin
noeloo wrote:
Wed Feb 17, 2021 2:23 pm
How is this _ used as a keyword? What is purpose of that?
It has no use or special meaning but it is now in the list of keywords. You can verify it here: https://docs.oracle.com/javase/specs/jl ... ml#jls-3.9