Course Internship Inheritance | ISC Computer Science Theory 2026 Sample Question

A superclass Course has been defined to store the basic details of a course. Define a subclass Internship to store internship-related information and calculate total earnings.

The details of both the members of the class are given below:

Class name: Course
Data members/instance variables:
title: to store the course title
duration: to store the course duration in months
Methods/Member functions:
Course(…): parameterized constructor to assign values to its data members
void show(): to display the course details

Class name: Internship
Data members/instance variables:
company: to store company name
stipend: to store the monthly allowance
totalEarnings: to store the total earnings
Methods/Member functions:
Internship(…): parameterized constructor to assign values to data members of both the classes
void calculate(): to calculate the total earnings as (stipend × duration)
void show(): to display course and internship details

Assume that the superclass Course has ben defined. Using the concept of Inheritance, specify the class Internship, giving details of the constructor, void calculate() and void show().

The super class, main() function and algorithm need not be written.

import java.util.Scanner;
class Course{
    protected String title;
    protected int duration;
    public Course(String t, int d){
        title = t;
        duration = d;
    }
    protected void show(){
        System.out.println("Course title: " + title);
        System.out.println("Duration: " + duration + " months");
    }
}
class Internship extends Course{
    String company;
    double stipend;
    double totalEarnings;
    public Internship(String t, int d, String c, double s){
        super(t, d);
        company = c;
        stipend = s;
    }
    public void calculate(){
        totalEarnings = stipend * duration;
    }
    public void show(){
        super.show();
        System.out.println("Company Name: " + company);
        System.out.println("Monthly Stipend: " + stipend);
        System.out.println("Total Earnings: " + totalEarnings);
    }
}
class Inheritance{
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        System.out.print("Course Title: ");
        String t = in.nextLine();
        System.out.print("Duration in months: ");
        int d = Integer.parseInt(in.nextLine());
        System.out.print("Company Name: ");
        String n = in.nextLine();
        System.out.print("Monthly Stipend: ");
        double s = Double.parseDouble(in.nextLine());
        Internship obj = new Internship(t, d, n, s);
        obj.calculate();
        obj.show();
    }
}