12 Replies Latest reply: Jun 21, 2011 10:16 PM by EJP RSS

    abstract class problem.

    870171
      hi;

      kindly confirm that following statement is true or false

      All the abstract methods present in the abstract super-class must be implemented by the first non abstract class.

      regards
      Pardeep Jangra
        • 1. Re: abstract class problem.
          796440
          Where did you read that?

          Why do you doubt it?

          What do you think is the answer, and why?
          • 2. Re: abstract class problem.
            802316
            867168 wrote:
            All the abstract methods present in the abstract super-class must be implemented by the first non abstract class.
            Say you could write the following
            abstract class A {
                abstract void method();
            }
            
            class B extends A { }
            
            A a = new B();
            a.method(); // what would you expect to happen here?
            • 3. Re: abstract class problem.
              870171
              i got this question from my mind. as from last 2 days i am learning abstract class concept.
              i just want to ask you people that which i am saying is right or wrong.
              if i am wrong then please provide me good examples.

              regards
              pardeep jangra
              • 4. Re: abstract class problem.
                870171
                hi;

                thanks for your kind reply.
                let us consider your example i am saying tha
                the method of class a must have body in class B.
                is it true or not?
                • 5. Re: abstract class problem.
                  798692
                  Not true. Here the method() is not an absract method.
                  • 6. Re: abstract class problem.
                    802316
                    Ram wrote:
                    Not true. Here the method() is not an absract method.
                    Sorry, it was meant to be abstract, there was no body defined
                    • 7. Re: abstract class problem.
                      EJP
                      You are wrong. Consider:
                      abstract class A
                      {
                        abstract void method();
                      }
                      
                      abstract class B extends A
                      {
                        void method(){}
                      }
                      
                      class C extends B
                      {
                      }
                      • 8. Re: abstract class problem.
                        798692
                        EJP wrote:
                        You are wrong. Consider:
                        abstract class A
                        {
                        abstract void method();
                        }
                        
                        abstract class B extends A
                        {
                        void method(){}
                        }
                        
                        class C extends B
                        {
                        }
                        OP mentioned that first non-abstract class. It is already a part of his point.
                        • 9. Re: abstract class problem.
                          EJP
                          OP mentioned that first non-abstract class.
                          The OP asked whether 'All the abstract methods present in the abstract super-class must be implemented by the first non abstract class.' I have just demonstrated that this isn't so. Class C is the first non-abstract class and it doesn't implement any methods at all. Ergo the OP is wrong.
                          It is already a part of his point.
                          It is already part of his question. I have answered it. What exactly you are doing is anybody's guess.
                          • 10. Re: abstract class problem.
                            796440
                            867168 wrote:
                            i got this question from my mind. as from last 2 days i am learning abstract class concept.
                            i just want to ask you people that which i am saying is right or wrong.
                            1. What do you think, and why

                            2. What did you observe when you tested it, an what do those observations tell you?

                            The more you show that you've put some effort into answering your own question, the more people will be willing to help you.
                            • 11. Re: abstract class problem.
                              870171
                              thanks EJP;

                              i got right answer. and no i am not confused. i am much confident about this topic.

                              Regards
                              pardeep jangra
                              • 12. Re: abstract class problem.
                                EJP
                                I got right answer
                                From me. I posted it. It would be courteous and professional for you to acknowledge that.
                                and no I am not confused.
                                Nobody said you were. I don't know what you are talking about here.
                                I am much confident about this topic.
                                Wonderful.