12 Replies Latest reply: Dec 16, 2008 3:52 PM by 807589 RSS

    Homework check? little bit of help/checking

    807589
      Could you guys check up on my homework?? I think I have most of them right, but some I cannot figure out. Thanks for the help

      7. What is the relationship of animal to bird in the following line of Java code:

      public class bird extends animal {

      a) bird overloads animal
      b) animal implements bird
      c) animal is a subclass of bird
      d) bird inherits from animal

      Answer: D is that correct?

      11. T or F: If a method is declared private, it cannot be called by anything outside of the class in which it’s declared.
      True

      14. T or F: Overloaded methods share the same method name.
      True

      15. T or F: Overloaded constructors must have the same number and type of arguments.
      False


      18. If a Java array n[x] contains 10 elements, what is the largest valid value of x?
      12?

      21. T or F: A reference-typed variable must be the same type as the object it references/contains. Explain.
      True? I am not sure how i can explain this.


      22. T or F: Multiple objects can be created from a single class. Explain your answer.
      True, but i also would like a clean explanation.


      24. What is the purpose of the ‘static’ keyword in Java?
      The purpose would be to create a class member that can be used by itself without reference to a specific instance.


      25. What special type of method must be defined for every class? This method is invoked when an object is instantiated from a class. What is this method used for? Provide an example.
      Not sure about this one.



      29. How does the ‘final’ keyword in Java affect inheritance of methods?
      Final keyword means that something or that "this" cannot be changed.


      30. If Willard creates a Java class named Foo without a toString() method, and then calls the toString() method on an instance of his class, it will produce output. Why is this?
      Not sure about this one as well.


      Any help or direction is appreciated. Thank you!
        • 1. Re: Homework check? little bit of help/checking
          807589
          18. If a Java array n[x] contains 10 elements, what is the largest valid value of x?
          12?
          Care to explain your answer?
          • 2. Re: Homework check? little bit of help/checking
            796447
            The ones you answered up thru #15 are all correct.
            For #18, why would you think 12 was the largest index value into an array of size 10?

            For the other questions which you are just saying "Give me the answer" in essense, do your own homework.
            • 3. Re: Homework check? little bit of help/checking
              807589
              misiomjod wrote:
              18. If a Java array n[x] contains 10 elements, what is the largest valid value of x?
              12?
              Remembering that array indexes are zero-based should help you with this one.
              • 4. Re: Homework check? little bit of help/checking
                807589
                drawimage wrote:
                misiomjod wrote:
                18. If a Java array n[x] contains 10 elements, what is the largest valid value of x?
                12?
                Remembering that array indexes are zero-based should help you with this one.
                I'm still trying to come up with a sane line of reasoning that yields 12.
                • 5. Re: Homework check? little bit of help/checking
                  807589
                  BigDaddyLoveHandles wrote:
                  drawimage wrote:
                  misiomjod wrote:
                  18. If a Java array n[x] contains 10 elements, what is the largest valid value of x?
                  12?
                  Remembering that array indexes are zero-based should help you with this one.
                  I'm still trying to come up with a sane line of reasoning that yields 12.
                  If I had to venture a guess, it would be that the OP just guessed without any logical reasoning behind it.
                  • 6. Re: Homework check? little bit of help/checking
                    807589
                    drawimage wrote:
                    BigDaddyLoveHandles wrote:
                    drawimage wrote:
                    misiomjod wrote:
                    18. If a Java array n[x] contains 10 elements, what is the largest valid value of x?
                    12?
                    Remembering that array indexes are zero-based should help you with this one.
                    I'm still trying to come up with a sane line of reasoning that yields 12.
                    If I had to venture a guess, it would be that the OP just guessed without any logical reasoning behind it.
                    [Then I've seen his math homework.|http://binza.blogspot.com/2007/02/funny-math-answers.html]
                    • 7. Re: Homework check? little bit of help/checking
                      807589
                      BigDaddyLoveHandles wrote:
                      drawimage wrote:
                      misiomjod wrote:
                      18. If a Java array n[x] contains 10 elements, what is the largest valid value of x?
                      12?
                      Remembering that array indexes are zero-based should help you with this one.
                      I'm still trying to come up with a sane line of reasoning that yields 12.
                      It's very simple--the 10 is actually base 13, so the highest valid value of x would be 12 (base 10).
                      • 8. Re: Homework check? little bit of help/checking
                        807589
                        morgalr wrote:
                        It's very simple--the 10 is actually base 13, so the highest valid value of x would be 12 (base 10).
                        Of course, it all makes sense now.
                        • 9. Re: Homework check? little bit of help/checking
                          807589
                          misiomjod wrote:
                          18. If a Java array n[x] contains 10 elements, what is the largest valid value of x?
                          12?
                          21. T or F: A reference-typed variable must be the same type as the object it references/contains. Explain.
                          True? I am not sure how i can explain this.


                          22. T or F: Multiple objects can be created from a single class. Explain your answer.
                          True, but i also would like a clean explanation.
                          Just think about it for a moment: what is a class--how does that relate to an object and how do you get an object?
                          24. What is the purpose of the ‘static’ keyword in Java?
                          The purpose would be to create a class member that can be used by itself without reference to a specific instance.
                          No.
                          25. What special type of method must be defined for every class? This method is invoked when an object is instantiated from a class. What is this method used for? Provide an example.
                          Not sure about this one.
                          Look at almost any Java class, what does it have and what is the very first piece of code that is run in that class when an object is created?
                          29. How does the ‘final’ keyword in Java affect inheritance of methods?
                          Final keyword means that something or that "this" cannot be changed.
                          Kind of--almost--but check your Java book on what "final" does before you try to turn that one in, you may want full credit.
                          30. If Willard creates a Java class named Foo without a toString() method, and then calls the toString() method on an instance of his class, it will produce output. Why is this?
                          Not sure about this one as well.
                          Where does the toString() come from? Go to the API and look at any class and logically follow methods until you get to a toString()--where did the toString() come from and what is that ability called in Java?
                          • 10. Re: Homework check? little bit of help/checking
                            807589
                            drawimage wrote:
                            morgalr wrote:
                            It's very simple--the 10 is actually base 13, so the highest valid value of x would be 12 (base 10).
                            Of course, it all makes sense now.
                            You know sometimes the OP's expect you to infure things... I'm just not sure the prof would make the same inference, but once his inference was made, I'm sure he would clearly articulate the grade.
                            • 11. Re: Homework check? little bit of help/checking
                              807589
                              Sorry about that, I meant to put 10 instead of 12(typo) in the first place but now I'd say that it's 9.
                              • 12. Re: Homework check? little bit of help/checking
                                796447
                                misiomjod wrote:
                                Sorry about that, I meant to put 10 instead of 12(typo) in the first place but now I'd say that it's 9.
                                Correct. Now do the rest of your homework yourself and ask specific questions if needed.