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
What is the core java?
What is default switch case? Give example.
How do you find the absolute value?
What is primitive data type in java?
What are some alternatives to inheritance?
How do you avoid global variables?
From the two, which would be easier to write: synchronization code for ten threads or two threads?
How do you define a singleton class?
What is the instance of an object?
Is there is any difference between a scrollbar and a scrollpane?
What do you understand by looping in java? Explain the different types of loops.
Can a serialized object be transferred via network?
What is main string [] args?
Do we have pointers in java?
Is 0 true or is 1 true?