Can a class extend abstract class or interface? why

Answers were Sorted based on User's Feedback



Can a class extend abstract class or interface? why..

Answer / swapna

Yes, a class can extends an abstract class.A class can
implement an interface not to extend an interface.
In abstract class can consist method signature not method's
defenation. Through class we can define the methods
defenation by using public access specifier. In class we
can override the methods of abstract class by using public
access specifiers. Same think will happen in also interface
case . B'coz we cannot directly create object of abstract
class and interface.
Ex:
abstract class A
{
abstract void show();
}
class B extends A
{
public void show()
{
System.out.println ("Hello java");
}
}
public class AbstA {

public static void main (String[] args)
{
B b=new B();
b.show();
}

}
out put: Hello java

Is This Answer Correct ?    17 Yes 1 No

Can a class extend abstract class or interface? why..

Answer / abhay bhatia

a class can extend an abstract class and can implement an
interface, why is because even though an abstract class
provide default implementation of its methods, we cannot
instantiate an object of the abstract class and therefore
need a class that extends it to use the instance methods of
this abstract class. An interface on the other hand cannot
even have default implementation, therefore it has to be
implemented to be used

Is This Answer Correct ?    3 Yes 0 No

Can a class extend abstract class or interface? why..

Answer / mahesh

A class can extend an Abstract class but it can't extend an
interface.

Is This Answer Correct ?    2 Yes 0 No

Can a class extend abstract class or interface? why..

Answer / ramakrishna

Yes, A class can extend an abstract class also any
interface,why because,A normal class which is implementing
an interface can still be declared as any abstract,if u
extend that class what happens?
u r extending an abstract class and indirectly extending
interface also.

Is This Answer Correct ?    1 Yes 3 No

Post New Answer

More Core Java Interview Questions

Explain an algorithm to find depth of a binary tree.

0 Answers   Akamai Technologies,


What is stream api in java8?

0 Answers  


what questions are been asked ??? for interview in apti

0 Answers  


What is the difference between a static and a non-static inner class in java programming?

0 Answers  


Is java util regex pattern thread safe?

0 Answers  






What is the difference between the Reader/Writer class hierarchy and the InputStream/OutputStream class hierarchy?

0 Answers  


Can you instantiate the math class?

0 Answers  


What is super keyword explain with example?

0 Answers  


Why method overriding is used?

0 Answers  


What is meant by distributed application? Why are we using that in our application?

0 Answers  


write SQL command for table employee where print first name or last name start like "A" and who is working in domain(angular js,java,dotnet)

1 Answers  


What are the allowed, non-Unicode letter characters that can be used as the first character of an identifier?

2 Answers  


Categories