Examveda
Examveda

What is the result of compiling and running the following code?
class Base{
        private Base(){
                System.out.print("Base");
        }
}
public class test extends Base{
        public test(){
                System.out.print("Derived");
        }
        public static void main(String[] args){
                new test();
        }
}

A. BaseDerived

B. Derived

C. Exception is thrown at runtime

D. Compilation Error

Answer: Option D

Solution(By Examveda Team)

Implicit super constructor Base is not visible, must explicitly invoke another constructor.


This Question Belongs to Java Program >> Declaration And Access Control

Join The Discussion

Related Questions on Declaration and Access Control