Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a class called GreenAlien which has the following public attributes: an attribute called name of type String. This holds the Aliens name. an attribute

Write a class called GreenAlien which has the following public attributes:

  • an attribute called name of type String. This holds the Aliens name.
  • an attribute called eyeCount of type int. This holds the number of eyes an Alien has.
  • an attribute called favouriteCandy of type String. This holds the Aliens perceived favourite candy.

And Methods:

  • getDescription, which returns the String: "This Alien is called and has eyes. Gross. It seems to enjoy eating ".

When you test your Class, make sure to have multiple instances of GreenAliens in your main() method. It's good to get used to having multiple objects of your code.

student submitted image, transcription available below 

Test GreenAlien gwerp = new GreenAlien(); gwerp.name = "Gwerp"; gwerp.eyeCount = 4; gwerp.favouriteCandy = "Marshmellows"; System.out.println(gwerp.getDescription()); Result This Alien is called Gwerp and has 4 eyes. Gross. It seems to enj

Step by Step Solution

3.43 Rating (153 Votes )

There are 3 Steps involved in it

Step: 1

class GreenAlien class GreenAlien public String nam... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Java An Introduction To Problem Solving And Programming

Authors: Walter Savitch

8th Edition

0134462033, 978-0134462035

More Books

Students also viewed these Programming questions

Question

Describe the concept of concurrency control.

Answered: 1 week ago

Question

What are the assumptions of the test based on the ????-ratio?

Answered: 1 week ago