Challenge: Animal Information Display
Tarea
Swipe to start coding
Your task is to bypass the private access modifier and create two objects with the necessary parameters, then display them.
- Create two objects of the
Animalclass — one for a cat and one for a dog.- You need to create an object
catof theAnimalclass with the type "Cat", name "Garfield", and color "Red". - You also need to create an object
dogof theAnimalclass with the type "Dog", name "Maks", and color "Black".
- You need to create an object
- Create and use the
Animal(String type, String name, String color)constructor to pass the parameterstype,name, andcolorfor each object. - After creating the objects, use
System.out.println()to print information about each animal.
Solución
¿Todo estuvo claro?
¡Gracias por tus comentarios!
Sección 1. Capítulo 13
single
Pregunte a AI
Pregunte a AI
Pregunte lo que quiera o pruebe una de las preguntas sugeridas para comenzar nuestra charla
Genial!
Completion tasa mejorada a 3.57
Challenge: Animal Information Display
Desliza para mostrar el menú
Tarea
Swipe to start coding
Your task is to bypass the private access modifier and create two objects with the necessary parameters, then display them.
- Create two objects of the
Animalclass — one for a cat and one for a dog.- You need to create an object
catof theAnimalclass with the type "Cat", name "Garfield", and color "Red". - You also need to create an object
dogof theAnimalclass with the type "Dog", name "Maks", and color "Black".
- You need to create an object
- Create and use the
Animal(String type, String name, String color)constructor to pass the parameterstype,name, andcolorfor each object. - After creating the objects, use
System.out.println()to print information about each animal.
Solución
¿Todo estuvo claro?
¡Gracias por tus comentarios!
Sección 1. Capítulo 13
single