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

When should you make a function static?

758


How many JVMs can run on a single machine and what is the Just-In-Time(JIT) compiler?

834


What will happen if there is a default method conflict as mentioned above and we have specified the same signature method in the base class instead of overriding in the existing class ?

758


What is static keyword?

806


Can we able to pass objects as an arguments in java?

808


How many types of constructors are used in java?

835


which pattern is default in scanner package?

2028


What are conditionals and its types?

862


What is an class?

794


Explain different types of wrapper classes in java?

812


Why is the type for real numbers called double?

763


What 5 doubled?

763


Write a function to find out longest palindrome in a given string?

840


What do you mean by singleton class in java?

705


What is heterogeneous in java?

740