Protected Constructor Example Java

A Java constructor can be anyone one of the four access specifiers Java supports – public, protected, default and private. An examples on Protected Constructor is given with screenshots. public class Demo { protected Demo() { System.out.println(“Hello 1”); } public static void main(String args[]) { Demo d1 = new Demo(); } } Replace protected with …

Protected Constructor Example Java Read More »