Can a class extend abstract class or interface? why

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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Is main an identifier?

764


What is enhanced loop in java?

747


Is java map thread safe?

710


What is a class reference?

772


Can You Have Virtual Functions In Java?

859


When a thread is executing synchronized methods , then is it possible to execute other synchronized methods simultaneously by other threads?

798


What is namespace in java?

769


How big is a 32 bit integer?

770


How to pass arraylist to stored procedure in java?

777


What comes to mind when someone mentions a shallow copy in java?

897


How to change the priority of thread or how to set the priority of thread?

833


How will you serialize a singleton class without violating singleton pattern?

1750


Is this valid in java ? Can we instantiate interface in java?

763


Do I need to import java.lang package any time? Why?

1052


Can a final variable be manipulated in java?

754