Single Choice Not Set

QWhat is the output for the below code ?
class A{
      private void printName(){
            System.out.println("Value-A");
      }
}
class B extends A{
      public void printName(){
            System.out.println("Name-B");
      }
}
public class Test{
      public static void main (String[] args){
            B b = new B();
            b.printName();
      }
}

ID: #2229 Overriding and Overloading in Java 1,809 views
Question Info
#2229Q ID
Not SetDifficulty
Overriding and Overloading in JavaTopic

Choose the Best Option

Click any option to instantly check if you're correct.

  • A Value-A
  • B Name-B
  • C Value-A Name-B
  • D Compilation fails - private methods can't be override
Correct Answer

Explanation

Name-B
No Previous Next Question

Share This Question

Challenge a friend or share with your study group.