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 java 9 released?

516


What are the types of java?

592


how would you implement a thread pool? : Java thread

493


How many types of threads are there in java?

492


explain what is transient variable in java?

607






Addition to previous section relative word 5th one was Putrid ans: rotten, also there was prob. in 1st section on bucket weight ans:10kg, also there was a prob. on train speed to find bridge length ans:800 mtrs.

1595


Can you explain the private protected field modifier?

557


What does the “final” keyword mean in front of a variable? A method? A class?

535


What is java regex?

521


What are predicates in java 8?

520


Is java still necessary?

607


What is the use of runnable interface?

592


What is the abstraction?

570


What design pattern you have used in your project? I answered Factory pattern, how it is implemented? What are its advantage? Do know about Abstract Factory?

1921


Can you make a constructor final?

562