What is an abstract class in Java An abstract class is class
What is an abstract class in Java
| An abstract class is class which cannot be instantiated |
Solution
What is an abstract class in Java
Answer:
An abstract class is class which cannot be instantiated
Explanation:
An abstract method is a method that has only declaration and doesn’t contain the definition.
An abstract class is a class which has one or more abstract method. These classes may not be instantiated, that is we cannot create objects for abstract classes they are implemented using subclasses. The class that extends the abstract class defines the abstract methods.
Example:
public abstract Greetings
{
public abstract void welcomeMsg(); //this is an abstract method
}
//this is the class that inherits the abstract class and implements the abstract method
public class SayHi extends Greetings
{
//defining the abstract method
public void welcomeMsg()
{
System.out.println(“Hello”);
}
}
| Answer: | An abstract class is class which cannot be instantiated |
