Home Answers Viewqa Java-Beginners Write Full concept of abstract class

 
 


kirankumar prabhakar gaware
Write Full concept of abstract class
1 Answer(s)      a year and 7 months ago
Posted in : Java Beginners

Abstract class

View Answers

October 3, 2011 at 4:58 PM


An abstract class is a class that is declared by using the abstract keyword. It may or may not have abstract methods. Abstract classes cannot be instantiated, but they can be extended into sub-classes.An abstract class can be extended into sub-classes, these sub-classes usually provide implementations for all of the abstract methods.

The key idea with an abstract class is useful when there is common functionality that's like to implement in a superclass and some behavior is unique to specific classes. So you implement the superclass as an abstract class and define methods that have common subclasses. Then you implement each subclass by extending the abstract class and add the methods unique to the class.

Points of abstract class :

1)Abstract class contains abstract methods.
2)Program can't instantiate an abstract class.
3)Abstract classes contain mixture of non-abstract and abstract methods.
4)If any class contains abstract methods then it must implements all the abstract methods of the abstract class.

Example of Abstract Class:

abstract class Animal {
  void runAnimal() {
    System.out.println("runAnimal() method called form Animal class"); // this
    // statement will override by the subclass method runAnimal
  }

  void printAnimal() {
    System.out.println("printAnimal() method called form Animal class");
  }
}

class BuzzwordAnimal extends Animal {
  void printAnimal() {
    System.out.println("printAnimal() method called form BuzzwordAnimal class");
  }

  void runAnimal() {
    super.runAnimal(); 
    // super keyword helps to call method of superclass ie Animal
    printAnimal(); // this invoke the buzzwordAnimal class method
  }
}

class AbstractExample {
  public static void main(String[] args) {
    BuzzwordAnimal b = new BuzzwordAnimal();
    b.runAnimal(); // overriding will take place as it has similar method
    // name exits both is sub and superclass
  }
}









Related Pages:
Write Full concept of abstract class
Write Full concept of abstract class  Abstract class
abstract class
abstract class   Explain the concept of abstract class and it?s use with a sample program.   Java Abstract Class An abstract class is a class that is declared by using the abstract keyword. It may or may not have
Abstract class and abstract method
be private because it defined in the other class. An abstract methods cannot... points about abstract methods are as following An abstract class may or may... also. An abstract class cannot be instantiated so it need to be a sub class
Java Abstract Class
to write the actual implementation code. An abstract class can be extended into sub... Java Abstract Class       An abstract class is a class that is declared by using the abstract keyword
wrapper class concept
wrapper class concept  Write a Java class that stores an integer item id, a string item name and a float price. Store all these in a String member Variable, separated by a space delimiter. Use an overloaded method to add
Abstract class
Abstract class  Can an abstract class be final
Abstract class
Abstract class  what is an Abstract class
abstract class
abstract class  Can there be an abstract class with no abstract methods
PHP Abstract Class
PHP Abstract Class: Abstract classes and methods are introduced in PHP 5. The concept behind the abstract class is that we need to extend this class by its descendant class(es). If a class contains abstract method then the class must
Abstract class
Abstract class  j   An Abstract class is a base class which... with an abstract keyword. For more information, visit the following links: http://www.roseindia.net/help/java/a/java-abstract-class.shtml http://www.roseindia.net/java
abstract class
abstract class  abstract class AbstractClass{ } is possible and compile the class or any compile time error occur tell me the answer Blockquote
abstract class
abstract class  what is abstract class .why we use it or what is the need of this class?   Abstract class is like base class which contains abstract method and cannot instantiated.   Please go through
write file in aplication folder with out giving full path - WebSevices
write file in aplication folder with out giving full path  i have a simple java class by the help of this java class i want to write file in application folder with out giving full path like c:/data/aa
Abstract class
Abstract class  Calendar cal=Calendar.getInstance() We know that Calendar is an abstract class so it can't be instantiated. So how we can say that cal is an instance of Calendar??? Beginner Question I suppose. Thanks in advace
IO concept
IO concept  Write a java program that moves the contents of the one file to another and deletes the old file.   Hi Friend, Try the following code: import java.io.*; class MoveFile{ public static void main(String
code for abstract class
code for abstract class  code for abstract class
What is an abstract class?
What is an abstract class?  What is an abstract class
Java abstract class
Java abstract class  Can an abstract class be final
Why Abstract Class?
Why Abstract Class?  What is the use of Abstract Class if it has Zero Abstract methods
Why Abstract Class?
Why Abstract Class?  What is the use of Abstract Class if it has Zero Abstract methods
variables and methods declared in abstract class is abstract or not
variables and methods declared in abstract class is abstract or not  variables and methods declared in abstract class is abstract
Abstract class,Abstract methods and classes
(); Abstract Class In java programming language, abstract classes... to implement the methods inherited from the abstract class (base class). Abstract classes are not instantiated directly. First extend the base class
abstract class - Java Beginners
abstract class  what exactly is abstract class and in which cases its... inherited from the abstract class (base class). Abstract classes... . e.g. abstract class A{ public abstract abs_value(); void show
Abstract class and interface in Java
Abstract class and interface in Java  What is the difference between abstract class and interfaces in Java?   Differences between an interface and an abstract class: At the same time multiple interfaces can
Interface vs abstract class
Interface vs abstract class  Hai, Is there any possible to defining abstract methods in Interface
Abstract class - Java Beginners
Abstract class  Why can use abstract class in java.?when abstract class use in java.plz Explain with program.   abstract class abs{ public void display(){ } public abstract void display1(); } public class win
Interface and Abstract class
and Abstract class? Give some example   Difference Between Interface and Abstract Class 1)Main difference is methods of a Java interface are implicitly abstract and cannot have implementations. A Java abstract class can have instance
Interface and Abstract class
is the difference between an Interface and an Abstract class?   hi, Very Good Question Abstract class is a class which contain one or more abstract methods and these method implemented by sub classes. Abstract class definition
full coding
full coding  class IdentifyMyParts { public static int x=7; public int y=3;} IdentifyMyParts a = new IdentifyMyParts(); IdentifyMyParts b = new IdentifyMyParts(); a.y = 5; b.y = 6; a.x = 1; b.x = 2; System.out.println("a.y
Inheritance, abstract classes
(); public abstract void getInfo(); } public class Checking extends Account...Inheritance, abstract classes  Hi. I wish to thank you for answering... will be thinking how could I write the code but not get the simplest part.I'm getting
RANDOM ACCESS FILE CONCEPT
RANDOM ACCESS FILE CONCEPT  Write a program that stores the names of four employees in an array of strings. Store the contents of the array... the RandomAccessFile class
Java Write
subclasses of  Writer abstract class are used to write on file... subclass CharArrayWriter of  abstract Writer class is used to write data... of  Writer abstract class are used to write on file
abstract method
abstract method  is final method is in abstract class
abstract method
abstract method  Can we have abstract class with no abstract methods
Java Abstract Class Example
Java Abstract Class Example In this section we will read about the Abstract class. Abstract class in Java is a class which is created for abstracting the behaviour of classes from the outside environment. Abstract class can be created
Abstract Class in Java
Abstract class in Java is a class that is declared using abstract keyword. It cannot be instantiated but can be extended into subclass. Abstract class cannot be instantiated means that new instances of an abstract class cannot
Explain final class, abstract class and super class.
Explain final class, abstract class and super class.  Explain final class, abstract class and super class.   Explain final class, abstract.... An abstract class is a class that is declared by using the abstract keyword. It may
abstract method
abstract method  Can a concrete class have an abstract method
what's the purpose of constructor in abstract class?
what's the purpose of constructor in abstract class?  what's the purpose of constructor in abstract class
What is an Abstract Class and what is it's purpose?
What is an Abstract Class and what is it's purpose?   Hi, What is an Abstract Class and what is it's purpose? Thanks
Can a abstract class be declared final?
Can a abstract class be declared final?   Hi, Can a abstract class be declared final? Thanks
abstract class - Java Interview Questions
abstract class  Explain the abstract class and abstract method...://www.roseindia.net/java/master-java/abstract-class.shtml http://www.roseindia.net/help/java/a/java-abstract-class.shtml Hope that it will be helpful for you. Thanks
Java write file
. In the example subclasses of  Writer abstract class are used to write... class.           Write_File... Java write file      
Interface Vs Abstract Class
Interface Vs Abstract Class      ... extend one class an abstract class may have some method implementation (non..., an interface is equivalent to a fully abstract class (a class with only public abstract
abstract class and interface - Java Beginners
abstract class and interface  what is the need for an abstract class? when should we use an abstract class? when should we use interface instead of abstract class?   Hi friend, Abstract classes In java
Java-Abstract Class - Java Beginners
Java-Abstract Class  Can a abstract class have a constructor ?When would the constructor in the abstract class be called ? Please give me with good...; Hi Friend, Yes. But Abstract class constructors will be called when its
abstract class and overriding - Java Beginners
abstract class and overriding  what is the difference between abstract class and overriding? Interface? Give some example program?   Hi friend, Abstract class : In java programming language, abstract classes
Class
Class, Object and Methods       Class : Whatever we can see in this world all the things... is termed as a class. All the objects are direct interacted with its class
Abstract class or methods example-1
;Animal class"); // this     // ...;form Animal class");   } } class ...;called form BuzzwordAnimal class");   }  
Can a abstract class be defined without any abstract methods?
Can a abstract class be defined without any abstract methods?   hi, Can a abstract class be defined without any abstract methods? thanks

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.