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
Is main an identifier?
What is enhanced loop in java?
Is java map thread safe?
What is a class reference?
Can You Have Virtual Functions In Java?
When a thread is executing synchronized methods , then is it possible to execute other synchronized methods simultaneously by other threads?
What is namespace in java?
How big is a 32 bit integer?
How to pass arraylist to stored procedure in java?
What comes to mind when someone mentions a shallow copy in java?
How to change the priority of thread or how to set the priority of thread?
How will you serialize a singleton class without violating singleton pattern?
Is this valid in java ? Can we instantiate interface in java?
Do I need to import java.lang package any time? Why?
Can a final variable be manipulated in java?