[Updated] Goldman Sachs Aptitude Test Questions and Answers
Practice List of TCS Digital Coding Questions !!!
Take 50+ FREE!! Online Data Interpretation Mock test to crack any Exams.

JAVA Programming :: Inheritance - Discussion

Home > JAVA Programming > Inheritance > MCQs Questions Discussion

9 / 9

What is the output for the below code?

public class A {
public void printName(){
System.out.println("Value-A");
}
}
public class B extends A{
public void printName(){
System.out.println("Name-B");
}
}
public class C extends A{
public void printName(){
System.out.println("Name-C");
}
}
public class Test{
public static void main (String[] args) {
B b = new B();
C c = new C();
b = c;
newPrint(b);
}
public static void newPrint(A {
printName();
}
}

AName-B

BName-C

CCompilation fails due to an error on lines 5

DCompilation fails due to an error on lines 9

Answer: Option (Login/Signup)

Show Explanation

Asked In ::

Post Your Answer Here:     

No Discussion on this question yet!