Question

In: Computer Science

What are the enumerators for the following enumeration data declaration? A)enum test {RED, YELLOW, BLUE, BLACK};...

What are the enumerators for the following enumeration data declaration?

A)enum test {RED, YELLOW, BLUE, BLACK};

B)enum test {RED, YELLOW=4, BLUE, BLACK};

C)enum test {RED=-1, YELLOW,BLUE, BLACK};

D)enum test {RED, YELLOW=6, BLUE, BLACK};

Solutions

Expert Solution

Correct Option: A

Except option A , remaining other options are incorrect declaration.

// In Correct Code

// Screenshot of the code & output

// Code to copy

public class EnumDemo
{
   enum test { RED, YELLOW, BLUE, BLACK };

   public static void main(String[] args) {
      
       test t=test.RED;
       System.out.println(t);
      
   }

}

In correct code

Explanation:

An enum is a special "class" that represents a group of constants (constants are public, static and final (unchangeable - cannot be overridden).

enum class - test  enumerator - RED, YELLOW, BLUE, BLACK


Related Solutions

Brian is selling balloons in 8 different colours: red, pink, yellow, blue, green, purple, black and...
Brian is selling balloons in 8 different colours: red, pink, yellow, blue, green, purple, black and silver. How many different selections of 16 helium balloons can be purchased if the shop has at least 16 balloons of each colour in stock? How many different selections of 16 helium balloons can be purchased if you buy at least 3 red balloons and at least 5 yellow balloons, and the shop has at least 16 balloons of each colour in stock? How...
What is the probability of drawing, in order, 2 red, 1 blue, and 2 yellow marbles if a bag contains 4 yellow, 5 red, and 6 blue marbles?
What is the probability of drawing, in order, 2 red, 1 blue, and 2 yellow marbles if a bag contains 4 yellow, 5 red, and 6 blue marbles?
A shop sells helium balloons in eight different colours: red, pink, yellow, blue, green, purple, black...
A shop sells helium balloons in eight different colours: red, pink, yellow, blue, green, purple, black and silver. (a) How many different selections of 16 helium balloons can be purchased if the shop has at least 16 balloons of each colour in stock? (b) How many different selections of 16 helium balloons can be purchased if you buy at least 3 red balloons and at least 5 yellow balloons, and the shop has at least 16 balloons of each colour...
Consider the following dataset: x1 Yellow Yellow Green Green Red Red Green Red Yellow x2 5...
Consider the following dataset: x1 Yellow Yellow Green Green Red Red Green Red Yellow x2 5 2 10 4 3 7 2 5 4 y 1 3 7 5 10 18 4 8 3 (a) (3pts) Split the data into a train and test set where the test set contains observations 1 and 7. Answer this by writing down the two datasets. (b) (2pts) Use Rstudio to estimate a model (which uses both x1 and x2 as predictor variables) using...
For a certain​ candy, 55​% of the pieces are​ yellow, 1515​% are​ red, 55​% are​ blue,...
For a certain​ candy, 55​% of the pieces are​ yellow, 1515​% are​ red, 55​% are​ blue, 2020​% are​ green, and the rest are brown. ​a) If you pick a piece at​ random, what is the probability that it is​ brown? it is yellow or​ blue? it is not​ green? it is​ striped? ​b) Assume you have an infinite supply of these candy pieces from which to draw. If you pick three pieces in a​ row, what is the probability that...
The colours red, blue, and yellow are known as the primary colours because they cannot be...
The colours red, blue, and yellow are known as the primary colours because they cannot be made by mixing other colours. When you mix two primary colours, you get one of following secondary colour: -Mix red and blue: purple -Mix red and yellow: orange -Mix blue and yellow: green Write a function colour_mix that takes two strings as parameters as two primary colours and returns the secondary colour. If the parameters are anything other than "red", "blue", or "yellow", the...
An urn has marbles of red, blue, and yellow. There are seven marbles of each of...
An urn has marbles of red, blue, and yellow. There are seven marbles of each of the three colors. The experiment consists of drawing a single, random marble from the urn. Define a random variable X by X(s) = -1 if the marble has red 0, if the marble has blue +1, if the marble has yellow 54 random samples of X are taken. Approximate the probability that the mean of the sample is between 0 and 1/20.
Twelve chairs are to be painted. The available colors are Red, Blue, Green, and Yellow, and...
Twelve chairs are to be painted. The available colors are Red, Blue, Green, and Yellow, and every chair must be painted with one color. Assuming that all coloring schemes are equally likely, what is the probability that one color is not used and there are at least two chairs of every other color ? (The answer is 0.25) Can anyone explain to me why ?
For a certain​ candy, 15​% of the pieces are​ yellow, 10​% are​ red, 15​% are​ blue,...
For a certain​ candy, 15​% of the pieces are​ yellow, 10​% are​ red, 15​% are​ blue, 20​% are​ green, and the rest are brown. ​a) If you pick a piece at​ random, what is the probability that it is​ brown? it is yellow or​ blue? it is not​ green? it is​ striped? ​b) Assume you have an infinite supply of these candy pieces from which to draw. If you pick three pieces in a​ row, what is the probability that...
For a certain candy, 15% of the pieces are yellow, 20% are red, 20% are blue,...
For a certain candy, 15% of the pieces are yellow, 20% are red, 20% are blue, 5% are green, and the rest are brown. a) If you pick a piece at random, what is the probability that it is​ brown? it is yellow or​ blue? it is not​ green? it is​ striped? b) Assume you have an infinite supply of these candy pieces from which to draw. If you pick three pieces in a​ row, what is the probability that...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT