ITSourceCode.com

We Exist to Provide 100% Free Source Code and Tutorials

Custom Search

Abstraction

Abstraction

Abstraction in Java is used to hide certain details and only show the essential features of the object. In other words, it deals with the outside view of an object (interface).

An abstract class contains an abstract keyword. An abstract class can or cannot have abstract methods.

A method that is declared as abstract and does not have implementation is known as abstract method.

Example:

An abstract class with abstract method:-

  1. abstract class Fan
  2. {
  3. abstract void run();
  4. }
  5.  
  6. class Havells extends Fan
  7. {
  8. void run()
  9. {
  10. System.out.println("Good speed");
  11. }
  12.  
  13. public static void main(String args[])
  14. {
  15. Fan obj = new Havells();
  16. obj.run();
  17. }
  18. }

Output:

Good speed

Facebook Comments

Check Your Domain Ranking

Leave a Reply

Your email address will not be published. Required fields are marked *

ITSourceCode.com © 2016 Frontier Theme

Subscribe For Latest Updates

Signup for our newsletter and get notified when we publish new articles for free!