+ 4

Can we inherit the private methods and objects of a public class ?

9th Jan 2017, 1:02 PM
Deep chand
Deep chand - avatar
6 Respostas
+ 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.
18th Jan 2017, 5:04 AM
xuyexu
xuyexu - avatar
+ 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
12th Jan 2017, 3:20 AM
Azure
Azure - avatar
+ 1
nope
27th Jan 2017, 12:34 PM
Catalin Popinciuc
Catalin Popinciuc - avatar
0
Just try it.
9th Jan 2017, 1:55 PM
Jonas Geiler
Jonas Geiler - avatar
0
No
12th Jan 2017, 2:46 AM
Al Dokhi Abdaullah
Al Dokhi Abdaullah - avatar
- 1
I think only objects you can inherit
12th Jan 2017, 4:30 AM
Pramod Patil
Pramod Patil - avatar