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 meant by binding in rmi?

0 Answers  


Java.util.regex consists of which classes?

0 Answers  


What do you mean by data type?

0 Answers  


What is an example of procedure?

0 Answers  


What is the difference between JVM and JRE?

0 Answers  






What is the byte range?

0 Answers  


public class AboutStrings{ public static void main(String args[]){ String s1="hello"; String s2="hel"; String s3="lo"; String s4=s2+s3; //to know the hash codes of s1,s4. System.out.println(s1.hashCode()); System.out.println(s4.hashCode()); // these two s1 and s4 are having same hashcodes. if(s1==s4){ System.out.println("s1 and s4 are same."); }else System.out.println("s1 and s4 are not same."); } } Somebody told me that, == operator compares references of the objects. In the above example even though s1 and s4 are refering to same object(having same hash codes), it is printing s1 and s4 are not same. Can anybody explain in detail why it is behaving like this? Thanks in Advance RavuriVinod

4 Answers   TCS,


What is hashmap in java?

0 Answers  


What is an exception? difference between Checked and Unchecked exception in Java

0 Answers   SkillGun Technologies,


Is break statement can be used as labels in java?

0 Answers  


What is java ceil?

0 Answers  


What is ternary operator in java?

0 Answers  


Categories