Page 1 of 1

[HD Pg 242, Sec. 9.2.3 - valid-combinations-of-access-modifiers-abstract-final-and-static]

Posted: Sat Jun 08, 2019 3:03 am
by flex567
Why is allowed for an abstract class to have concrete private instance methods?

Re: [HD Pg 242, Sec. 9.2.3 - valid-combinations-of-access-modifiers-abstract-final-and-static]

Posted: Sat Jun 08, 2019 3:29 am
by admin
Here are some questions that you should consider:
What do you think is the relation between the two things? Why do you think it should not be allowed?
What is the purpose of an abstract class? What is the purpose of a private instance method?

Re: [HD Pg 242, Sec. 9.2.3 - valid-combinations-of-access-modifiers-abstract-final-and-static]

Posted: Sat Jun 08, 2019 6:42 am
by flex567
I have found a use case for the private method:

Code: Select all

public class TestClass{

	abstract class  Cc{
		private void whap(){};
		public void doSomething(){  whap();  };
	}
	
	public static void main(String args[]){
	}
}