First please forgive me for the class names and the method names.
'My doubt is in class A the method "print" is declared protected .
So when class B inherits the Class A the method "print" becomes private in class B.
then when i execute B b=new B(); b.print(); in line 1 the sompiler must throw an error saying trying to access a private method.
Please quote the sources of the code snippet above.
Why would print() become private in B. Class B inherits class A, so it will inherit the method.
Child classes inherit the protected methods of parent classes. If you separate the packages though,
then only way you can access the protected method is through inheritance.