Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
i tried to create a calc class which will have methords of mathematical operators which are not in java already..........
now after i created it ....if i wat to use this class functions i will have to make it a super class for my new program but .....if i want my new program to have multiple attributes of diffrent classes .........and simultaneously use calc functions........but i cant..............
why java doesnt have multiple inheritances.......what are its advantages and disadvantages?
tnx in advanced...
Java doesn't support multiple inheritance because of the "diamond problem" and other problems that arise from "increased complexity and ambiguity" as is explained in the wikipedia page on the matter
The creators of Java had a design goal of simplicity. That is why operator overloading with the added complexity of the "copy constructor" was also left out. That is why there is automatic memory management etc etc
most modern languages chose to discard this concept for the same reason.
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I'm trying to understand the java 11 (JEP 309) dynamic class-file constants, it looks like an interesting feature.
and I google it, but I didn't find detailed articles (if you know any please share it) I just find this one by Rafael Winterhalter, but I still have some questions :
does this feature will make it possible to extend the types of constants that could be added to the pool (actually the pool could hold primitive and string values- correct me if I'm wrong)
in the article it is said that dynamic constant is generated as a result of invoking a bootstrap method, and that this method need to be referenced from the class’s constant pool, but how to do it (how to reference this method from class’s constant pool??)??.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
This question is not at all related to this one When is a function name too long?
Can execution speed suffer because you have a function with a long name that is going to be repeatedly called from numerous places thousands of times? Do optimization flags take care of this in compiled languages so that there is no problem? Then what about interpreted languages like python?
In (typical, static) compiled languages it doesn't matter at all, and has nothing to do with "optimization flags".
In such languages, the function names are strictly something used at compile-time to identify things. They are replaced with actual addresses (or offsets) in the final machine code. No name look-up occurs when you call a function in C.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I know abstract classes and interfaces in java but I want to know how to bring abstraction in working software/project? how to thing in such way which brings abstraction.
Your question is vague at best, however the usage of interfaces helps abstraction because you are not working with concrete types. For instance:
IPrinter p = PrinterFactory.getPrinter(conditions);
...
p.print(content);
In the below line, you are not aware of exactly what printer you are using. Since you are just using the logic, you do not really care. All that you care about is that the factory will give you the printer you are after and that the print method will print the content to the right stream.
If you want to change the printer being used, you make the amendments in the factory class so that you get a different IPrinter implementation which does what you need (which in this case it would be to print to some other media). This would mean that you have essentially changed the outcome of a piece of code without changing much of it.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
We are learning about both of these things in Java class right now. I believe I understand the basic aspects of both, but not sure about how Casting ends up limiting Algorithm Reuse. Our teacher said we need to know this for the test next week. Can anyone explain this?
If you cast you are limiting your algorithm to only work with one Class (or it's children). If you were instead to use an Interface you would be able to accept a greater variety of Objects that themselves implement that Interface. Much more flexible.
Here is a related SO question: Explaining Interfaces to Students
When you use casting in your code, you must know the exact type that you cast to (during the code write phase). Hence your code can't be reused in the future with different types. Always remember to program to interface instead of to specific type.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
As I was going through this java world article, it make reference to this. I tried to look through documentation, but could not find anything.
Polymorphism is just one of the governing principles of object oriented programming.
A program that is designed in an object-oriented style is one that uses classes to encapsulate individual pieces of functionality (encapsulation) and separates design from implementation (abstraction) using interfaces and/or abstract classes.
If you like, "OOP includes polymorphism", but "polymorphism by itself is not enough to define OOP".