A abstract class extending an abstract class.Super class
has both abstract and non-abstract methods.How can we
implement abstract and non-abstract mehtods? Explain with
snippet

Answer Posted / tulasi prasad

abstract class AbstractParent
{
void parentMethod1()
{
System.out.println("def of non abstract

method from parent");
}
abstract void parentMethod2();
}
abstract class AbstractChild extends

AbstractParent
{
void childMethod1()
{
System.out.println("def of non abstract

method from abstract child");
}
void parentMethod2()
{
System.out.println("def of parent abstract

method from abstract child");
}
abstract void childMethod2();
}
class ConcreteChild extends AbstractChild
{
void childMethod2()
{
System.out.println("def of child abstract

method from concrete child");
}
}
public class Test
{
public static void main(String args[])
{
ConcreteChild obj = new ConcreteChild();
obj.parentMethod1();
obj.parentMethod2();
obj.childMethod1();
obj.childMethod2();
}
}

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What data type is a string?

509


What is public/private protected in java?

539


What is wrapper class example?

529


What is the difference between stringbuffer and stringbuilder class?

560


Can a constructor be protected?

526






What are annotations in java?

616


What types of index data structures can you have in java?

606


what is a working thread? : Java thread

544


What is a private class in java?

504


What do you mean by formatting?

537


What is the difference between synchronized and synchronized block?

497


What is meant by design patterns?

575


What are the special characters?

531


Is there any sort function in java?

571


Where is the singleton class used?

579