+ 4
Can we inherit the private methods and objects of a public class ?
6 Answers
+ 3
No. first,A top-level class cannot be private or protected. It can have either public or no modifier. If it does not have a modifier it is supposed to have a default access. If a top level class is declared as private/protected the compiler will complain that the modifier private is not allowed here.
private - Only the current class will have access to the field or method.
protected - Only the current class and subclasses (and sometimes also same-package classes) of this class will have access to the field or method.
public - Any class can refer to the field or call the method.
+ 1
'When one class is inherited from another class, it inherits all of the superclass' non-private variables and methods.'
Go check look inheritance step 2
+ 1
nope
0
Just try it.
0
No
- 1
I think only objects you can inherit