www.pickatutorial.com Computer Tutorials
Top eBooks: C/C++ | C# | Android | Mathematics | Database | Cloud | Graphics | Networking | Oracle | Hardware | AI
Top Tutorials: C/C++ | C#.NET | PHP MySQL | Java | Java Script | jQuery | HTML | xHTML | HTML5 | VB Script| CSS
Lessons Abstract Classes and Methods Bookmark and Share
Tutorial Home
Lesson 1
Lesson 2
Lesson 3
Lesson 4
Lesson 5
Lesson 6
Lesson 7
Lesson 8
Lesson 9
Lesson 10
Lesson 11
Lesson 12
Lesson 13
Lesson 14
Lesson 15
Lesson 16
Lesson 17
Lesson 18
Lesson 19
Lesson 20
Lesson 21
Lesson 22
In this lesson we will learn about Abstract Classes and Abstract Methods in Java programming langauge.

Abstract Methods
An abstract method is a method that is declared in a (super)class, but not defined. In order to be instantiated, a subclass must provide the definition.

Abstract Classes
An abstract class is any class that includes an abstract method. It is similar to Pure virtual in C++. If a class includes an abstract method, the class must be declared abstract, too.

Code Example:
abstract class AbstractClass { 
   abstract public void Print(); 
   // no body, just the function header 
}
 
class MyConcreteClass extends AbstractClass { 
   public void Print() { 
   // actual code goes here 
   }
}
Important points to be remembered:
  • An abstract class cannot be instantiated.
  • A subclass of an abstract class that does not provide bodies for all abstract methods must also be declared abstract.
  • A subclass of a non-abstract class can override a (non-abstract) method of its superclass, and declare it abstract. In that case, the subclass must be declared abstract.

Next >>> Lesson No. 12: Java Interfaces







Home - Advertise - Contact - Disclaimer - About Us
© Since 2006 pickatutorial.com -- All Rights Reserved.