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

Answers were Sorted based on User's Feedback



A abstract class extending an abstract class.Super class has both abstract and non-abstract method..

Answer / 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

A abstract class extending an abstract class.Super class has both abstract and non-abstract method..

Answer / puneet khanna

If you have 2 abstract classes say Abstract Class A and
Abstract Class b where B extends A;

B may not implement the abstract methods from A but the
class which will inherit B will have to give the
implementation of the abstract methods from class A and B both.

Is This Answer Correct ?    1 Yes 0 No

A abstract class extending an abstract class.Super class has both abstract and non-abstract method..

Answer / 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

More Core Java Interview Questions

What is difference between stringbuffer and string?

0 Answers  


What is api in java?

0 Answers  


What is meant by 'bit masking' in java?

0 Answers   DELL,


Is JRE required to compile Java files ?

4 Answers   HCL,


what is Vector class?

2 Answers  


How to extract HashMap values?

5 Answers   Marlabs,


Name the class that used to read objects directly from a stream?

4 Answers   Wipro,


what is difference between signed & unsigned char?

2 Answers  


What are the three parts of a lambda expression? What is the type of lambda expression?

0 Answers  


Explain the selection sort algorithm and state its time complexity?

0 Answers   Flextronics,


What is replaceall in java?

0 Answers  


how to identify duplicate values in arraylist

2 Answers   TCS,


Categories