My Blog
Articles related to programming, computer science, technology and research.

Java program on rodent hierarchy

07/06/2016 Categories: Inheritance. Comments Off on Java program on rodent hierarchy

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 and override these in the derived classes to perform different behaviors, depending on the specific type of Rodent. Create an array of Rodent, fill it with different specific types of Rodents […]

Read the rest of this entry »

Java program on shape hierarchy

07/06/2016 Categories: Inheritance. Comments Off on Java program on shape hierarchy

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 extends the class Shape. Each one of the classes contains only the method numberOfSides( ) that shows the number of sides in the given […]

Read the rest of this entry »

Java program that illustrates how runtime polymorphism is achieved

07/06/2016 Categories: Inheritance. Comments Off on Java program that illustrates how runtime polymorphism is achieved

Java program that illustrates how runtime polymorphism is achieved.

Output for the above program is as follows: Area of triangle is: 300 Area of rectangle is: 600

Read the rest of this entry »
Scroll Up