Abstract Classes and Interfaces in Java for ISC Class 12 (with Programs)
ISC Class 12 Computer Science notes on abstract classes and interfaces in Java: abstract methods, implementing interfaces, constants in interfaces, multiple interfaces, the key differences, and a solved board-style program.

After inheritance, the next step in ISC Class 12 Java is abstraction: describing *what* a class must do without saying *how*. Java gives you two tools for this, abstract classes and interfaces. Both appear in theory questions and in Section C programs.
Abstract methods and abstract classes
An abstract method has a heading but no body. It ends with a semicolon:
abstract double area();A class that contains an abstract method must be declared abstract:
abstract class Shape {
String name;
Shape(String n) {
name = n;
}
abstract double area(); // no body: every subclass must define it
void show() { // concrete method: shared by all subclasses
System.out.println(name + " area = " + area());
}
}Key rules:
- You cannot create an object of an abstract class:
new Shape("x")is an error. - A subclass must override every abstract method, or be declared abstract itself.
- An abstract class can have constructors, data members and normal (concrete) methods.
class Square extends Shape {
double side;
Square(double s) {
super("Square");
side = s;
}
double area() {
return side * side;
}
}new Square(4).show() prints Square area = 16.0.
Interfaces
An interface is a completely abstract type: a list of methods that a class promises to provide.
interface Payable {
double TAX_RATE = 0.18; // constant: public static final by default
double amountDue(); // abstract: public abstract by default
}- The methods in an interface are public and abstract by default. (Since Java 8, interfaces can also have
defaultandstaticmethods, but ISC questions focus on abstract methods.) - Variables in an interface are constants: automatically
public static final. - A class uses an interface with the keyword implements, and must define all its methods.
class Invoice implements Payable {
double price;
Invoice(double p) {
price = p;
}
public double amountDue() { // must be public
return price + price * TAX_RATE;
}
}new Invoice(1000).amountDue() returns 1180.0.
The implementing method must be declaredpublic, because interface methods are public. Leaving outpublicis a common compile error.
Multiple interfaces
A class can extend only one class, but it can implement many interfaces. This is how Java achieves the effect of multiple inheritance:
class SmartPhone extends Device implements Camera, MusicPlayer {
// must define all the methods of Camera and MusicPlayer
}Abstract class vs interface
- Methods: an abstract class can have both abstract and concrete methods; interface methods are abstract by default.
- Variables: an abstract class can have any instance variables; an interface can only have constants (public static final).
- Constructors: an abstract class can have them; an interface cannot.
- Keyword: a class
extendsan abstract class butimplementsan interface. - How many: a class can extend only one class, but can implement many interfaces.
Solved board-style program
Question: An interface Data has a constant PI = 3.14 and a method double volume(). Define a class Cylinder that implements Data, with the data members radius and height, a parameterised constructor, the method volume() that returns πr²h, and a method display() that prints the radius, the height and the volume.
interface Data {
double PI = 3.14;
double volume();
}
class Cylinder implements Data {
double radius, height;
Cylinder(double r, double h) {
radius = r;
height = h;
}
public double volume() {
return PI * radius * radius * height;
}
void display() {
System.out.println("Radius: " + radius);
System.out.println("Height: " + height);
System.out.println("Volume: " + volume());
}
}For radius 2 and height 5, the volume is 3.14 × 4 × 5 = 62.8. Java may print a tiny rounding difference in the last decimal place, because double arithmetic is not exact.
Practice questions
- Can an abstract class have a constructor? Why would it need one?
- What is the default access of a method declared in an interface?
- Why does Java not allow
class C extends A, B?
Answers:
- Yes. It initialises the common data members, and subclasses call it with
super(...). - public (and abstract).
- To avoid ambiguity when both A and B have a method with the same signature (the "diamond problem"). Java uses interfaces instead.
Revise Inheritance in Java first, then continue with Stacks, Queues and Linked Lists for ISC Class 12.
Related Posts
Continue learning with these related articles

Inheritance in Java for ISC Class 12: super, Method Overriding and Solved Programs
ISC Class 12 Computer Science notes on inheritance in Java: superclass and subclass, the extends and super keywords, protected members, method overriding, types of inheritance, and a fully solved board-style program.

Karnaugh Maps (K-Maps) for ISC Class 12: SOP and POS Reduction Step by Step
A complete ISC Class 12 Computer Science guide to Karnaugh maps: cell numbering for 3- and 4-variable maps, grouping rules, SOP and POS reduction with fully solved examples, and the mistakes that cost marks in the board exam.

ISC Practical 2027: Sentence and Date (Vowels, Future Date, Sort by Length) – Algorithm and Java Program
Fully solved ISC Computer Science Practical 2027 blended question: validate a sentence and a date, count the vowels, add that many days to the date (handling month, year and leap-year changes) and sort the words by length while keeping the original order for ties.