Java: why can't a method be private and abstract at the same time? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 5

Java: why can't a method be private and abstract at the same time?

18th Aug 2019, 6:38 PM
Paolo De Nictolis
Paolo De Nictolis - avatar
1 Answer
+ 14
Because if you declare a method as a private, then that method is only accessible in withen class. But if you put an abstract keyword in that method, it means that method is either inside the interface or inside the abstract class. and you know very well if you declare method as abstract that means that method is not definable in that interface or in that abstract class. So if you delcare method as private and abstract at the same time that mens this method is unusable.So you cannot keep the method private and abstractat a time.
18th Aug 2019, 8:24 PM
Sumit Programmer😎😎
Sumit Programmer😎😎 - avatar