In the following code, I am getting the output Hello. Can anyone explain why compiler is not reporting an error it I am calling a protected function outside the class and inheritance chain.
package sampleproject;
public class SampleProject
{
public static void main(String[] args)
{
Sample s=new Sample();
s.finalize();
}
}
class Sample
{
@Override
protected void finalize()
{
System.out.println("Hello");
}
}
Thanks.