[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 :: Objects and Classes - Discussion

Home > JAVA Programming > Objects and Classes > MCQs Questions Discussion

25 / 30

Choose the correct option.

What is the output for the below code ?

public class A {
public void printValue(){
System.out.println("A");
}
}
public class B extends A {
public void printValue(){
System.out.println("B");
}
}
1. public class Test {
2. public static void main(String... args) {
3. A b = new B();
4. newValue(b);
5. }
6. public static void newValue(A {
7. if(a instanceof B){
8. ((B).printValue();
9. }
10. }
11. }

AA

BB

CCompilation fails with an error at line 4

DCompilation fails with an error at line 8

Answer: Option (Login/Signup)

Show Explanation

Asked In ::

Post Your Answer Here:     

No Discussion on this question yet!