Given:1. public class Base {2. public static final String FOO = "foo";3. public static void main(String[] args) {4. Base

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899559
Joined: Mon Aug 02, 2021 8:13 am

Given:1. public class Base {2. public static final String FOO = "foo";3. public static void main(String[] args) {4. Base

Post by answerhappygod »

Given:1. public class Base {2. public static final String FOO = "foo";3. public static void main(String[] args) {4. Base b = new Base();5. Sub s = new Sub();6. System.out.print(Base.FOO);7. System.out.print(Sub.FOO);8. System.out.print(b.FOO);9. System.out.print(s.FOO);10. System.out.print(((Base)s).FOO);11. } }12. class Sub extends Base {public static final String FOO="bar";}What is the result?

A. foofoofoofoofoo
B. foobarfoobarbar
C. foobarfoofoofoo
D. foobarfoobarfoo E. barbarbarbarbar F. foofoofoobarbar G. foofoofoobarfoo
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!

This question has been solved and has 1 reply.

You must be registered to view answers and replies in this topic. Registration is free.


Register Login
 
Post Reply