0% found this document useful (0 votes)
5 views1 page

Online Java Compiler for Inheritance Demo

The document contains a Java program demonstrating inheritance. It defines a base class with a method to display a number and a derived class that sets this number and calls the display method. The main class creates an instance of the derived class and invokes the solution method with a value of 50.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views1 page

Online Java Compiler for Inheritance Demo

The document contains a Java program demonstrating inheritance. It defines a base class with a method to display a number and a derived class that sets this number and calls the display method. The main class creates an instance of the derived class and invokes the solution method with a value of 50.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

// Online Java Compiler

// Use this editor to write, compile and run your Java code online
import [Link];

class base{
int num;
void display()
{
[Link](num);
}

}
class ProblemSolution extends base {
void solution(int N)
{
num = N;
display();
}

public class InheritanceDemo {


public static void main(String[] args) {
ProblemSolution ps = new ProblemSolution();
[Link](50);
}
}

You might also like