Question

7. Which of the following statements is not true about subclass methods? Why? a. A subclass can override methods in a superclass. b. A subclass can define new methods that are not in the superclass. A subclass can inherit methods in a superclass. A subclass can access private methods in a superclass A subclass can access public methods of its superclass.
0 0
Add a comment Improve this question Transcribed image text
Answer #1

d. A subclass can access private methods in a super class.

A subclass cannot access private methods in a superclass. The reason is that, subclasses do not inherit private members of a super class, so you cannot call those methods directly but through any other public methods which has a call to the actual private method.

Add a comment
Know the answer?
Add Answer to:
Which of the following statements is not true about subclass methods? Why? a. A subclass can...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • In Java Which of the following statements declares Salaried as a subclass of payType? Public class...

    In Java Which of the following statements declares Salaried as a subclass of payType? Public class Salaried implements PayType Public class Salaried derivedFrom(payType) Public class PayType derives Salaried Public class Salaried extends PayType If a method in a subclass has the same signature as a method in the superclass, the subclass method overrides the superclass method. False True When a subclass overloads a superclass method………. Only the subclass method may be called with a subclass object Only the superclass method...

  • (1)     ____ is the principle that allows you to apply your knowledge of a general category...

    (1)     ____ is the principle that allows you to apply your knowledge of a general category to more specific objects.           a.       Inheritance              c.       Encapsulation           b.       Polymorphism                    d.       Override (2)     When you create a class by making it inherit from another class, you are provided with data fields and ____ automatically.           a.       fonts                      c.       class names           b.       methods                  d.       arrays (3)     By convention, a class diagram contains the ____ following each attribute or...

  • Question 83 (1 point) To create a subclass, use the ___ keyword. extends implements interface inherits...

    Question 83 (1 point) To create a subclass, use the ___ keyword. extends implements interface inherits O Question 84 (1 point) Which of the following is true regarding inheritance? A superclass can force a programmer to override a method in any subclass created from it. A superclass cannot prevent a programmer from overriding a method in any subclass created from it. When creating a subclass, all methods of the superclass must be overridden. When creating a subclass, no methods of...

  • Which one of the following statements is true? If a subclass constructor makes a super) call...

    Which one of the following statements is true? If a subclass constructor makes a super) call with a non-empty list of parameters, then the parameter types must be well defined in the superclass. Abstract classes do not need a constructor since they cannot be instantiated. Each subclass constructor must contain an explicit super() method. For each subclass constructor, there must be a corresponding superclass constructor with the same signature.

  • Java CSE 135 Which methods does the ChoiceQuestion class inherit from its superclass? Which methods does...

    Java CSE 135 Which methods does the ChoiceQuestion class inherit from its superclass? Which methods does it override? Which methods does it add? public class Question{ . . . public void display() { System.out.println(text); }} public class ChoiceQuestion extends Question{ . . . public void display() { super.display(); for (int i = 0; i < choices.size(); i++) { int choiceNumber = i + 1; System.out.println(choiceNumber + ": " + choices.get(i)); } }} public class QuestionDemo{ public static void main(String[] args)...

  • 1.   What will be the value of x after the following code is executed? int x...

    1.   What will be the value of x after the following code is executed? int x = 10, y = 20; while (y < 100) { x += y; } A.   90 B.   110 C.   210 D.   This is an infinite loop 2.   If a superclass has constructor(s): A.   then its subclass must initialize the superclass fields (attributes). B.   then its subclass must call one of the constructors that the superclass does have. C.   then its subclass does not inherit...

  • Assume Superis the name of a superclass and Subis the name of a subclass. If we...

    Assume Superis the name of a superclass and Subis the name of a subclass. If we have: Super s = new Sub(); we can only invoke the methods defined in Super class, and we cannot access the methods added by the Sub class. Is this statement true or false? A. true B. false I appreciate if you put some descritions

  • In the first exercise, you will override the add method in a subclass in order to...

    In the first exercise, you will override the add method in a subclass in order to improve its performance. In the second exercise, you will implement an Iterator for your new linked list class. Exercise 1 The add method of the linked list class discussed during lecture performs in O(N) time. What can be done to improve its performance to O(1)? What are the boundary cases? Define a new class that inherits from the CS20bLinkedList class introduced during the lecture....

  • java Which of the following is an incorrect statement about subclass constructors? A superclass constructor is...

    java Which of the following is an incorrect statement about subclass constructors? A superclass constructor is invoked from a subclass constructor by using the keyword "super" and passing any necessary arguments. Every subclass constructor must be an explicit constructor. Every subclass constructor must call a superclass constructor. The superclass constructor call must be the first action performed by a subclass constructor.

  • C++ programing Which of the following statements (a-d) are true if the following lines of code...

    C++ programing Which of the following statements (a-d) are true if the following lines of code are executed? int G = 17; int &H = G; A. H is now an alternate name for G B. Adding 1 to H will change the value of G to 18 C. Subtracting 5 from G and printing H will display the value 12 D. The condition H == G will give a true result E. All of the statements (a-d) are true...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT