SECTION A: True/False 1 When you use inheritance in Java, you can create a new c
ID: 3736494 • Letter: S
Question
SECTION A: True/False 1 When you use inheritance in Java, you can create a new class that contains all the data and methods of an existing class. 2 When you use inheritance, you save time and reduce errors 3 A class that is used as a basis for inheritance is called a subclass. 4 You use the keyword inherits to achieve inheritance in Java. 5 A derived class has access to all its parents' nonprivate methods. 6 Subclasses are more specific than the superclass they extend. 7 Any child class object has all the attributes of its parent, but all of those attributes might not be directly accessible. You override a parent class method by creating a child class method with the same identifier but a different parameter list or return type. When a child class method overrides a parent class method, and you use the method name with a child class object, the child class method version executes. 10 Information hiding describes the concept of keeping data private. 1A subclass inherits all the data and methods of its superclass, except the private ones If a data field is defined as protected, then a method in a child class can use it directly. 12 13 14 15 A subclass cannot override methods that are declared static in the superclass. A subclass cannot override methods that are declared final in the superclass. A subclass cannot override methods that are declared private in the superclass.Explanation / Answer
ANSWER 1: False, because in Java we cannot override instance variables but we can override methods.
ANSWER 2: Yes it is true because by using parent class methods we can save our time.
ANSWER 3: Yes it is true.
ANSWER 4: false because we use extends keyword to inherit in java.
ANSWER 5: Yes it true.
ANSWER 6: True because subclass contains both parent and its specific methods and variables so it is more specific.
ANSWER 7: False because child class can you all attributes of parents class except private variables.
ANSWER 8: False because in the overriding process it is not allowed it can do in overloading.
ANSWER 9: Yes it is true.
ANSWER 10: Yes it is true by private keyword we can achieve the data hiding concept.
ANSWER 11: YEs it is true.
ANSWER 12: If it is in the same package then we access.
ANSWER 13: True, Static methods can not be overridden because they are not part of the object's state. Rather, they belong to the class (i.e they are class methods). It is ok to overload static (and final) methods. No, Static methods can't be overridden as it is part of a class rather than an object.
ANSWER 14: Final methods cannot be overridden because the purpose of the "final" keyword is to prevent overriding.
ANSWER 15:No, a private method cannot be overridden since it is not visible from any other class.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.