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 string example?
Difference between start() and run() method of thread class?
What does sprintf mean?
Write a code to create a trigger to call a stored procedure
What are filterstreams?
Which arithmetic operations can result in the throwing of an arithmeticexception?
What must a class do to implement an interface in java programming?
What does you mean in math?
How can the checkbox class be used to create a radio button?
Explain creating threads by extending thread class ?
Is java a prime method?
State the merge-sort principle and its time complexity.
Which variable is the independent variable?
Explain static nested classes ?
What is string english?