Startertutorials Blog
Tutorials and articles related to programming, computer science, technology and others.
Subscribe to Startertutorials.com's YouTube channel for different tutorial and lecture videos.
Home » Programming » Java » Programs » Inheritance

Java program for demonstrating inheritance and method overriding

Suryateja Pericherla Categories: Inheritance. No Comments on Java program for demonstrating inheritance and method overriding

Aim To write a program for demonstrating inheritance and method overriding.   Theory Inheritance Inheritance is defined as: Deriving properties and behavior of one class to another class. The class from which things are derived is known as super class and the class in to which things are derived to is known as sub class. […]

Read the rest of this entry »

Java program on rodent hierarchy

Suryateja Pericherla Categories: Inheritance. No Comments on Java program on rodent hierarchy

In this article we will learn to implement a Java program on rodent hierarchy. A Java program is provided below which uses the rodent hierarchy to demonstrate inheritance in Java.   Java program to create an inheritance hierarchy of Rodent, Mouse, Gerbil, Hamster etc. In the base class provide methods that are common to all Rodents […]

Read the rest of this entry »

Java program on shape hierarchy

Suryateja Pericherla Categories: Inheritance. No Comments on Java program on shape hierarchy

In this article we will learn to implement a Java program on shape hierarchy. The requirements for writing the program is specified below.   Java program to create an abstract class named Shape that contains an empty method named numberOfSides( ).Provide three classes named Trapezoid, Triangle and Hexagon such that each one of the classes […]

Read the rest of this entry »

Java program that illustrates how runtime polymorphism is achieved

Suryateja Pericherla Categories: Inheritance. No Comments on Java program that illustrates how runtime polymorphism is achieved

In this article we will learn to implement a Java program that illustrates how runtime polymorphism is achieved. A Java program is provided below that demonstrates how runtime polymorphism is achieved. abstract class Figure { int dim1, dim2; Figure(int x, int y) { dim1 = x; dim2 = y; } abstract void area(); } class […]

Read the rest of this entry »
Facebook
Twitter
Pinterest
Youtube
Instagram
Blogarama - Blog Directory