Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within foundations
Search Coderanch
Advance search
Google search
Register / Login
Win a copy of
OCP Oracle Certified Professional Java SE 21 Developer Study Guide: Exam 1Z0-830
this week in the
Programmer Certification
forum!
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Tim Cooke
Liutauras Vilda
Jeanne Boyarsky
paul wheaton
Sheriffs:
Ron McLeod
Devaka Cooray
Henry Wong
Saloon Keepers:
Tim Holloway
Stephan van Hulst
Carey Brown
Tim Moores
Mikalai Zaikin
Bartenders:
Frits Walraven
Forum:
Java Foundations Exam
inheritance by interface in java[1Z0-808]
Tiam Bezalel
Ranch Hand
Posts: 67
posted 2 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
hi,
assuming that static members are not inherited in
java
, why is
Magic3.magicNum
a problem? also, I think it should not be accessed.
thanks
interface Magic1 { int magicNum = 7; } interface Magic2 { int magicNum = 8; } interface Magic3 extends Magic1, Magic2 { } public class Test { public static void main(String[] args) { System.out.println(Magic1.magicNum + Magic2.magicNum + Magic3.magicNum); } }
To conquer without peril, one ends up triumphing without glory
Alexander Zotz
Ranch Hand
Posts: 56
posted 2 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Magic3 have access to both static variables from Magic1 and Magic2.
Magic3.magicNum is a ambigous call (compiler dont know which static variable from both it should use)
Magic1.magicNum calls 7 and Magic2.magicNum calls 8.
Create symphonies in seed and soil. For this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
OCA Exam 1Z0-808
Oracle Certified Associate Java SE 8 Programmer 1 STUDY GUIDE EXAM 1Z0-808 Assessment Test 1 Q 14
Sybex 1Z0-815, Chapter 7, Review question 10
Preparing for 1Z0-808 - Need challenging problems to study/solve
Kindly explain this code from SCJP faq
More...