GeekInterview.com
Series: Subject: Topic:
Question: 685 of 995

abstract class A
{
void display()
{}
}
class B extends A
{
void display()
{}
psvm(String args[])
{

how can i instantiate the overridden method in class A
}
}

Asked by: Interview Candidate | Asked on: Oct 27th, 2005
Showing Answers 1 - 4 of 4 Answers
Alok

Answered On : Oct 27th, 2005

 A a1 = new b();

a1.display();

  
Login to rate this answer.
Devidas

Answered On : Nov 14th, 2005

A a1= new B(); a1.display();

  
Login to rate this answer.

abstract class A


{


    void
display()

    {

    }

}

class B extends A


{


    void
display()

    {


        super
.display();


        -----------------
    }


    public
static void main(String args[])


    {

       
B b1=new B();


       
b1.display();
    }

}

  
Login to rate this answer.
r.praveenkumar

Answered On : Apr 10th, 2009

View all answers by r.praveenkumar

all three answers above are correct. in 3rd one we are assigning object of B to reference of B itself. But in first and second answers we are assigning object of B to Reference of A. In all three cases JVM will invoke B's display() only.

  
Login to rate this answer.

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

Related Open Questions

Ads

Connect

twitter fb Linkedin GPlus RSS

Ads

Interview Question

 Ask Interview Question?

 

Latest Questions

Interview & Career Tips

Get invaluable Interview and Career Tips delivered directly to your inbox. Get your news alert set up today, Once you confirm your Email subscription, you will be able to download Job Inteview Questions Ebook . Please contact me if you there is any issue with the download.