Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
J

jude martin 99

@jude martin 99
About
Posts
2
Topics
2
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Polymorphism Java Programming Help
    J jude martin 99

    I am a beginner in Java Programming and I just started programming as a hobby. I am in need of help in my Polymorphism program. How do I create an application that has an array of some size, say 5. The array should be defined of the superclass type. Then create 5 objects where each class is represented at least once. Store the objects created into the array elements. Finally, have the application go to each element of the array and call the display method. I should find that the display method automatically called is the one defined in the object stored in the element. I already have a superclass which is animal and two subclasses dog and cat and a polymorphism application mainclass Polymorphism Application: MainClass

    public class MainClass {

    public static void main(String \[\] args)
    {
    	Animal a = new Animal();
    	a.displayName("Generic Animal");
    
    	Cat c = new Cat();
    	c.displayName("Fluffy");
    
    	Animal dog = new Dog();
    	dog.displayName("Scooby-Doo"); // Polymorphic method call -- Dog IS-A Animal
    
    	Animal cat = new Cat();
    	cat.displayName("Mittens");   // Polymorphic method call -- Cat IS-A Animal
    }
    

    }

    Superclass (Animal):

    public class Animal
    {
    public void displayName(String name)
    {
    System.out.println("My name is " + name);
    }
    }

    Subclass (Cat):

    public class Cat extends Animal
    {
    public void displayName(String name)
    {
    System.out.println("My name is " + name + " and I like to drink milk.");
    }
    }

    Subclass (Dog):

    public class Dog extends Animal
    {
    public void displayName(String name)
    {
    System.out.println("My name is " + name + " and I like to eat Scooby Snacks!");
    }
    }

    Java java data-structures oop help question

  • Java Linked Lists (JAVA Beginner in need of help)
    J jude martin 99

    How do I create an application that uses a linked list. It must be able to do at least the following to the linked list: check whether the list is empty display the list find the length of the list destroy the list retrieve the data in the nth node search the list for a given item insert an item in the list delete an item from the list I need help on how to start it and help in executing the actions from the list above I'm just a beginner in Java Programming

    Java java data-structures help tutorial question
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups