1 2 Previous Next 29 Replies Latest reply on Aug 11, 2009 6:58 PM by 807588 Go to original post
      • 15. Re: Abstract class
        796125
        jverd wrote:
        So, your definition of "abstract" is "contains at least one abstract method," rather than "is declared abstract"?
        This was not my proposition, but I'll put in my two cents:

        Not necessarily. I would suggest that simply by declaring a class abstract, you can safely say that it is "not concrete", on the basis that an abstract class cannot be instantiated. It must therefore be specialized by subclassing, before it can be of use.

        The concept of abstraction refers to selectively removing information from a problem, thus making the problem and solution (or partial solution) more generalized, and therefore, re-usable in other contexts. To obtain an abstract class more concrete, you must supply additional information.

        In the case of an abstract class containing no abstract methods, the additional information that must be supplied before the class can be used to solve your problem is the actual run-time type of the object, and almost certainly, some extra methods, or replacements for existing methods, in order to alter the behavior of the original abstract class. Otherwise, it would be of no use to label the original class abstract.

        In short, it seems to me that the only value in making a class abstract is to declare that more information is necessary in order to obtain a complete solution to the problem at hand, so the class is an abstraction of the solution you are looking for.

        - Adam
        • 16. Re: Abstract class
          796125
          arihant.nn wrote:
          Can I have an abstract class in which all the methods are defined. I mean can i make a concrete class (which has all it's methods well defined ) preceded by the abstract keyword.
          Side note to the OP: You can achieve the results of preventing a class from being instantiated, but still fully specifying all of it's methods by simply making the constructor protected. This way, only subclasses can be instantiated.

          - Adam
          • 17. Re: Abstract class
            YoungWinston
            georgemc wrote:
            Answer: yes and no, respectively
            Which leaves the OP no better off than when s/he started. How about this:
            In answer to your question: yes; however you are misusing the word 'concrete' as understood by Java programmers.

            Winston
            • 18. Re: Abstract class
              YoungWinston
              guitar_man_F wrote:
              In short, it seems to me that the only value in making a class abstract is to declare that more information is necessary in order to obtain a complete solution to the problem at hand, so the class is an abstraction of the solution you are looking for.
              Don't quite agree with you there. I think it's perfectly possible to want to define a skeleton class with 'defaults' for all possible methods - if you like a method-based version of a Builder pattern.

              Winston
              • 19. Re: Abstract class
                807588
                arihant.nn wrote:
                ... can i make a concrete class (which has all it's methods well defined ) preceded by the abstract keyword.
                Your question is made ambiguous by your use of the words "have" and "make". Do you mean
                "can I define an abstract class where every method has an implementation"
                or do you mean
                "can I instantiate an abstract class where every method has an implementation".
                • 20. Re: Abstract class
                  796440
                  georgemc wrote:
                  jverd wrote:
                  georgemc wrote:
                  YoungWinston wrote:
                  georgemc wrote:
                  Scorpiongiri wrote:
                  yes
                  Actually, if you want to give a simple yes/no answer to the original question, the correct answer would be "no", since, by definition, a concrete class cannot be declared using the 'abstract' keyword
                  I'll pitch in for Scorpiongirl here. According to OP's initial question, the answer is 'yes'. Arguing about Java semantics, while important, is secondary.
                  I'm not talking about Java semantics, and I respectfully disagree that this is secondary. Although there is a Java keyword abstract, the concepts of abstract and concrete in this context are not specific to Java, or even software engineering. The OP needs to know that something concrete cannot also be abstract. Sure, the answer to the first question is "yes", but as qualified by the second question, the OP clearly misunderstands what concrete class means. Answering one question whilst ignoring the other is misinforming
                  So, your definition of "abstract" is "contains at least one abstract method," rather than "is declared abstract"?
                  Nope. Where do I imply that?
                  " the concepts of +abstract+ and +concrete+ in this context are not specific to Java, or even software engineering. The OP needs to know that something concrete cannot also be abstract."

                  I assumed your concrete/abstract definitions for this context were based on the presence or absence of unimplemented methods. If that's not it, what is it? Clearly it can't be "declared abstract", since obviously a fully implemented class can be declared abstract.


                  >
                  Can I have an abstract class in which all the methods are defined. I mean can i make a concrete class (which has all it's methods well defined ) preceded by the abstract keyword.
                  Answer: yes and no, respectively
                  So, for the first one, what is your definition of "abstract class"? Above you say that it's NOT that the class contains at least one abstract method, so, what kind of class in Java is abstract, other than "one which has at least one abstract method"?
                  • 21. Re: Abstract class
                    796440
                    guitar_man_F wrote:
                    In short, it seems to me that the only value in making a class abstract is to declare that more information is necessary in order to obtain a complete solution to the problem at hand,
                    I agree. But that really doesn't have anything to do with the OP's question.
                    • 22. Re: Abstract class
                      796440
                      YoungWinston wrote:
                      georgemc wrote:
                      Answer: yes and no, respectively
                      Which leaves the OP no better off than when s/he started. How about this:
                      In answer to your question: yes; however you are misusing the word 'concrete' as understood by Java programmers.

                      Winston
                      Better still: What are you trying to do? Why does this matter?
                      • 23. Re: Abstract class
                        796440
                        YoungWinston wrote:
                        guitar_man_F wrote:
                        In short, it seems to me that the only value in making a class abstract is to declare that more information is necessary in order to obtain a complete solution to the problem at hand, so the class is an abstraction of the solution you are looking for.
                        Don't quite agree with you there. I think it's perfectly possible to want to define a skeleton class with 'defaults' for all possible methods - if you like a method-based version of a Builder pattern.
                        Right. But why make it abstract unless you're saying "This isn't useful without something being added"? If it's useful as-is, why make it abstract?
                        • 24. Re: Abstract class
                          YoungWinston
                          jverd wrote:
                          YoungWinston wrote:
                          Don't quite agree with you there. I think it's perfectly possible to want to define a skeleton class with 'defaults' for all possible methods - if you like a method-based version of a Builder pattern.
                          Right. But why make it abstract unless you're saying "This isn't useful without something being added"? If it's useful as-is, why make it abstract?
                          I thought I'd already explained it, but OK; let's take, for example AbstractList.
                          To my mind, it would be perfectly reasonable to create all the code based around an array (don't forget that AbstractList is, by default, immutable). So, in my program, I have:
                          List<String> myList = new AbstractList<String>(myArray) {};
                          and have it behave exactly like a wrapper to a String array (with possible UnsupportedExceptions, of course);

                          How useful it would be is another matter :-).

                          Winston

                          Edited by: YoungWinston on Aug 11, 2009 11:18 AM
                          Oops. Forgot the array.
                          • 25. Re: Abstract class
                            YoungWinston
                            jverd wrote:
                            Better still: What are you trying to do? Why does this matter?
                            Fair enough, but in this case I did think the OP was fairly clear about his intention; he just got a piece of Java terminology wrong.

                            Winston
                            • 26. Re: Abstract class
                              796440
                              YoungWinston wrote:
                              jverd wrote:
                              Better still: What are you trying to do? Why does this matter?
                              Fair enough, but in this case I did think the OP was fairly clear about his intention; he just got a piece of Java terminology wrong.

                              Winston
                              My impression is more that he wanted to know if something was legal syntax and couldn't be bothered to do any research on his own.
                              • 27. Re: Abstract class
                                YoungWinston
                                jverd wrote:
                                My impression is more that he wanted to know if something was legal syntax and couldn't be bothered to do any research on his own.
                                jverd, you're becoming a cynic. Pity the poor junior; we were all there once :-).

                                Winston
                                • 28. Re: Abstract class
                                  796440
                                  YoungWinston wrote:
                                  jverd wrote:
                                  My impression is more that he wanted to know if something was legal syntax and couldn't be bothered to do any research on his own.
                                  jverd, you're becoming a cynic.
                                  Becoming? Pfft. That train left the station long ago.
                                  Pity the poor junior; we were all there once :-).
                                  I know, and I'm not begrudging anybody a noob's uncertainty and confusion. Based on what I've seen here over the last 10 years, however, the OP's question reads to me like plain ol' lazy.
                                  • 29. Re: Abstract class
                                    807588
                                    YoungWinston wrote:
                                    georgemc wrote:
                                    Answer: yes and no, respectively
                                    Which leaves the OP no better off than when s/he started. How about this:
                                    In answer to your question: yes; however you are misusing the word 'concrete' as understood by Java programmers.
                                    Good point. Best go tell ScorpionGirl
                                    1 2 Previous Next