What happens if constructor of class A is made private

By Rebecca
1 Min Read

What happens if constructor of class A is made private?

(a) Any class can instantiate objects of class A

(b) Objects of class A can be instantiated only within the class where it is declared

(c) Inherited class can instantiate objects of class A

(d) classes within the same package as class A can instantiate objects of class A

Answer:

(b) Objects of class A can be instantiated only within the class where it is declared

What happens if constructor of class A is made private

Read more: Which of them is not a wireless attack

Posted by Rebecca
Follow:
Rebecca is an Independent content writer for breldigital, She writes content on any given topic. She loves to write a case study article or reviews on a brand, Be it any topic, she nails it