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 / srinu
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 A1
{
public static void main(String args[])
{
ConcreteChild obj = new ConcreteChild();
obj.parentMethod1();def of non abstract method from parent
obj.parentMethod2();def of parent abstract method from
abstract child
obj.childMethod1();def of non abstract method from abstract
child
obj.childMethod2();def of child abstract method from
concrete child
}
}
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
Why are pointers not secure?
What is the core java?
Explain the difference between treeset and treemap in java?
Explain the difference between jdk, jre, and jvm?
How finally used under exception handling?
Can abstract class have private constructor?
Wha is the output from system.out.println(“hello”+null); ?
Why do we need strings in java?
How are variables stored?
What is static in java?
What is int lol?
Why call by value prevents parameter value change?
What are different types of inner classes ?
What is the difference between an inner class and a sub-class?
What is the best way to findout the time/memory consuming process?