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
What is the use of beaninfo?
What is array initialization in java?
Why is string class considered immutable?
What is the method in java?
If an application has multiple classes in it, is it okay to have a main method in more than one class?
Does collectionutils isempty check for null?
What is a void method?
What is sortedmap in java?
What is byte code and why is it important to java’s use for internet programming?
Where are the card layouts used?
Is char a data type in java?
What is an infinite loop? How infinite loop is declared?
Can we restart a dead thread in java?
why Interface used?
What does java ide mean?