SCJP Module-1 Question-26

The Sample program given below will test your understanding about the abstract class and Inheritance in Java.

 
 

Share on Google+Share on Google+

SCJP Module-1 Question-26

Ads

The Sample program given below will test your understanding about the abstract class and Inheritance in Java.

Given a sample code:

abstract class A {
abstract void a1();

void a2() {
System.out.print(" A");
}
}

class B extends A {
void a1() {
}

void a2() {
System.out.print(" B");
}
}

class Test extends B {
public static void main(String[] args) {
{
A y = new B();
y.a2();
Test z = new Test();
z.a2();
}}}

What will be the result? Choose the correct option?

(A) A A
(B) A B
(C) B B
(D) B A

Answer:

(C)

Advertisements

Posted on: July 21, 2010 If you enjoyed this post then why not add us on Google+? Add us to your Circles