Best Answer

//We Declare an abstract class as-

abstract class Car



//Example of an abstract method

abstract void hondaCity(); //no method body and abstract

//Example of Abstract class that has an abstract method

abstract class Car


abstract void run();


class HondaCity extends Car


void run()


System.out.println("runs smartly");


public static void main(String args[])


Car obj = new HondaCity();;



//OUTPUT will be-

runs smartly

User Avatar

leela pandey

Lvl 2
โˆ™ 2020-03-18 06:11:32
This answer is:
User Avatar
Study guides


1 card


See all cards
23 Reviews
More answers
User Avatar

Wiki User

โˆ™ 2009-10-16 23:55:24

You use the "abstract" keyword.

// Normal class
class A {}

// Abstract class
abstract class A{}

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How do you declare class as an abstract?
Write your answer...
Still have questions?
magnify glass
Related questions

Can you declare final method in abstract class?

Yes, you can declare a final method in an abstract class. However, that method cannot be abstract itself.

When do you declare a method or class abstract?

public abstract class class_namne{ public abstract void method() {} }

When do you declare a method or class abstract in java?

when overriding of a class or a method is necessary, they can be declared as abstract

What is an abstract class Write the syntax Declare a pure virtual function in an abstract class?

an abstract class is nothing but class which contains both abstract and concrete methods for abstract class we r nt create object Syntax for pure abstract class is abstract class x { public void abstract y(); public void abstract z(); public void abc() { }

What are the differences between class and abstract class?

Normal variables or static variables are declared and use in class but abstract class had only static variables. You have declare and define the methods in class. But abstract class only allow for method declaration only. The abstract class like interface.

What is abstract class and abstract method?

An Abstract method is one that has only a method declaration and no method definition. Similarly an abstract class is one that has one or more abstract methods. You can declare an abstract class or methods by using the keyword abstract in the class definition. Ex: public abstract class TestAbsClass { abstract void method1(); } Any class that extends this abstract class must provide implementation to the method "method1" or else it would have to be abstract as well.

What is the keyword used to declare a class which cannot be instantiated?

abstract all lower case.

What happens if an abstract modifier is applied to class. Explain?

The classes which have one or more abstract methods are abstract. To declare a class as abstract, use the abstract keyword in front of the class keyword, before the class declaration. Abstract classes cannot be instantiated. Similarly the new keyword cannot be used to create an object of the abstract class. Remember that the constructors and static variables cannot be declared as abstract. Any subclass of an abstract class must either implement all of the abstract methods in the superclass or be itself declared abstract.

Is it necessary to implement all the methods of abstract classes in derived class?

Yes - It is Necessary to implement all methods of the abstract class in your class - If you want a concrete class that can be instantiated. If you dont plan on implementing all methods, then you have to declare your current class too as Abstract. Abstract classes are generally used where you want an amount of behaviour to be used by the class that extends the abstract class while at the same time giving options to the child class to provide a certain amount of behaviour itself.

Declaration What is the abstract noun for declare?

Yes, the abstract noun form of the verb to declare is declaration.

Can an abstract class inherit from another abstract class in c plus plus?

Yes an abstract class can inherit from another abstract class but all the methods of the base abstract class must be abstract.

What is purpose of An Abstract Class in java?

Abstract keyword used for method declaration declares the methods without implementations. Abstract class in java have abstract methods that is not implemented in abstract class, but implemented in subclasses in java program. If the class in java program is not required to get instantiated than that class use the abstract keyword but this class rather is available for other classes to extend by other classes. Abstract keyword will be used in method declaration to declare that method without providing the implementation in that java program. In other words we can say that, it formally unfinished class as well as method, that marked with the help of keyword abstract. Defining abstract is a way of preventing someone from instantiating a class that is supposed to be extended first. In java program abstract class is deliberately missing similar to like an interface which will missing all method bodies in the program. Abstract class provides a way to extend an actual class. We will not use new on abstract classes but will use abstract references in the java program, that always point to objects of the class that extends an abstract class. In java program for practical use of an abstract class, we will define a non-abstract class that extends an abstract one. This will use any of the inherited non-abstract methods. Most of the time abstract class may extend another abstract class. In that condition it need not implement all in the non-abstract methods. An abstract keyword used both on classes and methods. In case of class declared with an abstract keyword may not be instantiated that is the only thing that abstract keyword doing.

People also asked