Inheritance Abstract class program
Write a java program that implements educational hierarchy using inheritance. In this program abstract class is used. An abstract class can't be instantiated(you can't create an object of these classes). An abstract class is a class which has at least one abstract method. An abstract method can't ha
Abstract class program
JAVA videos
Write a java program that implements educational hierarchy using inheritance.
In this program abstract class is used. An abstract class can't be instantiated(you can't create an object of these classes). An abstract class is a class which has at least one abstract method. An abstract method can't have a method body, it has to be implemented by the class which is inheriting this abstract class.

import java.util.Scanner;
abstract class Office
{
int empNo;
String empName;
int salary;
abstract void getData();
}
class Teaching extends Office
{
String designation;
void setData()
{
Scanner sc = new Scanner(System.in);
System.out.print("Enter Employ number => ");
empNo = sc.nextInt();
System.out.print("Enter Employ name => ");
empName = sc.next();
System.out.print("Enter salary => ");
salary = sc.nextInt();
System.out.print("Enter designation => ");
designation = sc.next();
}
void getData()
{
System.out.println("Employ name => " + empName + "\t\tEmploy number => " + empNo);
System.out.println("Salary => " + salary + "\t\tDesignation => " + designation);
}
}
class Non_teaching extends Office
{
String designation;
void setData()
{
Scanner sc = new Scanner(System.in);
System.out.print("Enter Employ number => ");
empNo = sc.nextInt();
System.out.print("Enter Employ name => ");
empName = sc.next();
System.out.print("Enter salary => ");
salary = sc.nextInt();
System.out.print("Enter designation => ");
designation = sc.next();
}
void getData()
{
System.out.println("Employ name => " + empName + "\t\tEmploy number => " + empNo);
System.out.println("Salary => " + salary + "\t\tDesignation => " + designation);
}
}
public class Practical14
{
public static void main(String[] args)
{
Teaching t1 = new Teaching();
Non_teaching nt1 = new Non_teaching();
System.out.println("Data about Teaching class => \n");
t1.setData();
t1.getData();
System.out.println("\n\nData about Non teaching class => \n");
nt1.setData();
nt1.getData();
}
}
Inheritance of interface
Related Posts
Continue learning with these related articles

Logic Gates for ISC Class 11: Truth Tables, Universal Gates, Half and Full Adder
ISC Class 11 Computer Science notes on logic gates: AND, OR, NOT, NAND, NOR, XOR and XNOR with truth tables, why NAND and NOR are universal gates, and half adder and full adder circuits with their Boolean expressions.
Decimal to Binary Conversion in Java: 3 Programs with Examples
How to convert a decimal number to binary on paper and in Java: three programs (String, place value and Integer.toBinaryString), binary to decimal, a dry run and common mistakes.

ISC Class 11 Computer Science Sample Paper 2026-27 with Solutions
A full 70-mark ISC Class 11 Computer Science sample paper for the 2026-27 annual exam: MCQs, number systems, propositional logic, logic gates, Java classes, arrays, strings, searching and sorting, and computing ethics, with complete worked solutions.