Siksha Sarovar

Siksha Sarovar (sikshasarovar.com) is a free educational web application that helps students in India learn programming and prepare for academic and competitive exams. The platform offers structured coding courses (C, C++, Python, Java, HTML, CSS, PHP, Power BI, AI, Machine Learning, Data Science), complete university curriculum notes for BCA/MCA students with previous year question papers, Class 10 and Class 12 CBSE/HBSE school notes, and dedicated preparation material for SSC, UPSC, Banking, Railway and other government exams. Browsing the site is completely free and requires no account. Users may optionally sign in with Google solely to save their learning progress, quiz scores and personal preferences across devices.

Privacy Policy | Terms of Service | Contact Siksha Sarovar | About Siksha Sarovar

v4.0.9 · PWA
Siksha Sarovar logo
Siksha Sarovar
Your Learning Universe

Siksha Sarovar is a free e-learning platform for coding courses, BCA university notes and competitive exam preparation. Optional Google sign-in saves your learning progress across devices.

Initializing knowledge base…
Compiling modules 0%

Abstraction

Lesson 24 of 39 in the free Java notes on Siksha Sarovar, written by Rohit Jangra.

Abstraction

It is the design process of hiding the implementation and showing only the functionality (declaration) to the user.

Ways to Achieve

  1. Abstract Classes (0 to 100% abstraction)
  2. Interfaces (100% abstraction)

Abstract Modifier

Keyword: abstract. Applicable for methods and classes.

Abstract Method

A method prefixed with abstract, having no implementation (ends with semicolon). • Syntax: abstract [access_mod] returnType methodName(args); • Known as "Incomplete Method". • Rules:

  • Cannot be private, static, or final.
  • Child class is responsible for implementation.

Abstract Class

A class prefixed with abstract. • Cannot define an object (Instance) for an abstract class. • Can consist of both abstract and concrete methods. • If a class has at least one abstract method, the class must be declared abstract. • Constructor: Allowed (invoked via constructor chaining).

Implementation Rules:

  1. If a class extends an abstract class, it must implement all abstract methods.
  2. If it fails to do so, the subclass must also be declared abstract.

When to use Abstract Methods? • When we don't have a clear idea about implementation. • To force child classes to provide their own implementation.