Science, asked by sumanshiri, 5 hours ago

Which of the following statements is/are not true?
Members declared as protected in super class will be inherited only by the sub classes within the same package
Constructor of super class is inherited by a sub class
Members with default access specifier cannot be inherited by sub classes in other packages
Private methods of super class is not inherited by the sub class​

Answers

Answered by jubin22sl
0

Answer: The false options are

Constructor of super class is inherited by a sub class

Class: Class definitions in object-oriented programming are templates for the methods and variables of a certain object type. To put it another way, an object represents an actual instance of a class. Object-oriented programming is defined by the concept of classes.

Explanation:

  • There are several different types of super classes in object-oriented programming. A subclass is a class that inherits the code from its parent class. instance variables and member functions of the parent class are often passed down to the subclass.
  • Constructors aren't members, therefore subclasses don't inherit them

#SPJ2

Answered by AncyA
0

Answer:

The incorrect statement is Constructor of super class is inherited by a sub class.

Explanation:

Members declared as protected in super class will be inherited only by the sub classes within the same package

  • The above statement is true. The declared protected super classes like variables, constructors,  and methods can be assessed by the protected member's class of subclass of other package or any class within the package.

Members with default access specifier cannot be inherited by sub classes in other packages

  • The above statement is true. The protected members are allowed in the same package and are also accessible in the other packages. But the members with default access specifier cannot be inherited by sub class in other packages.

Private methods of super class is not inherited by the sub class​

  • The above statement is true. Because The subclass does not inherit the super class of private methods.

Constructor of super class is inherited by a sub class

  • The above statement is False. Constructor are not members and are not inherited by the sub class. But the constructor of super class can be invoked by the subclass.
  • A subclass is a class that inherits the code from its parent class. instance variables and member functions of the parent class are often passed down to the subclass.
  • The incorrect statement is Constructor of super class is inherited by a sub class

#SPJ3

Similar questions