Q. 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
πŸ’¬ Discuss
βœ… Correct Answer: (D) Compilation Error
Explanation: Implicit super constructor Base is not visible, must explicitly invoke another constructor.
Explanation by: Ravi Shankar
Implicit super constructor Base is not visible, must explicitly invoke another constructor.

πŸ’¬ Discussion


πŸ“Š Question Analytics

πŸ‘οΈ
140
Total Visits
πŸ“½οΈ
1 y ago
Published
πŸŽ–οΈ
Ravi Shankar
Publisher
πŸ“ˆ
95%
Success Rate