Oracle
1Z0-851 · Question #38
Given: public class Base { public static final String FOO = "foo"; public static void main(String[] args) { Base b = new Base(); Sub s = new Sub(); System.out.print(Base.FOO)…
The correct answer is D. foobarfoobarfoo. See the full explanation below for the reasoning.
Question
Given: public class Base { public static final String FOO = "foo"; public static void main(String[] args) { Base b = new Base(); Sub s = new Sub(); System.out.print(Base.FOO); System.out.print(Sub.FOO); System.out.print(b.FOO); System.out.print(s.FOO); System.out.print(((Base)s).FOO); } } class Sub extends Base {public static final String FOO="bar";} What is the result?
Options
- Afoofoofoofoofoo
- Bfoobarfoobarbar
- Cfoobarfoofoofoo
- Dfoobarfoobarfoo
- Ebarbarbarbarbar
- Ffoofoofoobarbar
- Gfoofoofoobarfoo
How the community answered
(33 responses)- A3% (1)
- C9% (3)
- D85% (28)
- G3% (1)
Community Discussion
No community discussion yet for this question.