answersLogoWhite

Top Answer
User Avatar
leela pandey
Answered 2020-03-18 06:11:32

//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();

obj.run();

}

}

//OUTPUT will be-

runs smartly

012
๐Ÿ™
0
๐Ÿคจ
0
๐Ÿ˜ฎ
0
๐Ÿ˜‚
0
User Avatar

User Avatar
Wiki User
Answered 2009-10-16 23:55:24

You use the "abstract" keyword.

// Normal class
class A {}

// Abstract class
abstract class A{}

001
๐Ÿ™
0
๐Ÿคจ
0
๐Ÿ˜ฎ
0
๐Ÿ˜‚
0
User Avatar

Your Answer

Related Questions


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


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


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


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() { }


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.


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.



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.


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.


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


Abstract classes are to be extended until to a concrete class.Can have both abstract & non abstract methods.An Abstract class can not be instantiated.A non abstract class can be extended to an abstract class.If At least one abstract method present in a class then that class must be abstract.abstract & final modifiers can never be together.abstract classes can have both abstract methods & non abstract methods.


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


Abstract keywordused 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.


No! abstract is a key word for saying "Don't make a reference variable of this class" A interface is a abstract class and you have to implement it. When you do this all your doing is making sure that what ever class your putting in to wont compile unless less you at least declare the method. It doesn't have to do anything or event have a body.


The abstract keyword signifies that the particular method will have no features in the class where it is declared and it is upto the child class to provide the functionality. In case of an interface, the method is already abstract by default and has no code inside it. So there is no actual point in using the abstract keyword there.


An abstract factory class is a class which has an abstract method to create an object.


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.


Any class which has one or more abstract methods is called an abstract class. But in the normal class we can't have any abstract methods. We cannot create an object for the abstract classes. When we inherit the abstract class we should implement the abstract method which we inherit.


a abstract class is class which has a abstract method which means a method does not its own body.


If a class has one abstract method ,the class has to be an abstract class.Methods can be implemented in abstract class.Whereas a interface is like a abstract class...the only difference being that the methods are never implemented in Interface.


A constructor of a class in invoked when a object of that class is created. As an abstract class can't have an object, so we can't create a constructor of the abstract class. But we can create a constructor of a concrete subclass of that abstract class and we have to pass the object of that concrete subclass to the abstract class.


An abstract class cannot have a constructor and hence you cannot invoke the constructor of the class - i.e., you can instantiate an abstract class and hence you cannot call the constructor of an abstract class.


Abstract method has no body(only declare). To use an abstract method you have to override it .


An abstract class is one that has one or more abstract methods. i.e., methods that have only a declaration and no implementation. A fully abstract class is one that has only abstract methods and does not provide implementation to even one method in the class. A fully abstract class is equal to an interface.


abstract is keyword this is used for define abstract methods and abstract classes.abstract method means if you want define a method with out any body at that time you should define a method with abstract keyword. EX:public abstract int add() { } if you want define a class with abstract method must and should you define a class will be abstract class. Abstract EX:abstract class abc { abstract methods ------------ non abstract methods ---------------- } you can define abstract as well as non abstract methods in abstract class. in normal class you can define only normal methods only. you can't acess the methods which are in the abstract class from the same clss.by child class only you can acess the methods which are in abstract class. if you want to inherit abstract class must and should you have to define abstract methods which are in abstract class. Interface ----------:- interface is also like a clss.in interface you have to define only abstract methods only.you can't define normal methods in interface. EX: interface abc { abstract methods } by inharitance only you can acess the methods what are in the interface through the class.



Copyright ยฉ 2021 Multiply Media, LLC. All Rights Reserved. The material on this site can not be reproduced, distributed, transmitted, cached or otherwise used, except with prior written permission of Multiply.