1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Ghella [55]
3 years ago
6

You need to write a class called SingleItemBox (in a file called SingleItemBox.java that you create). This class has a construct

or that takes a single item (of any type) and puts it in the box. You also need a method called getItem() which provides the item back to the user but does not remove it from the box (this is an "accessor", if you remember, sometimes called a "getter"). Make sure to comment your code as you go in proper JavaDoc style. Please implement this code using generics concept in java.
Computers and Technology
1 answer:
fgiga [73]3 years ago
7 0

Answer:

class SingleItemBox<ItemType> {

 

  ItemType box;

  SingleItemBox(ItemType item) {

      this.box = item;

  }

  public ItemType getitem() {

      return this.box;

  }

}

public class Main {

  public static void main(String[] args) {

      SingleItemBox <Integer> intObj = new SingleItemBox(10);

      System.out.println(intObj.getitem());

     

      SingleItemBox <String> sObj = new SingleItemBox("banana");

     

      System.out.println(sObj.getitem());

  }

}

Explanation:

  • Inside the singleItemBox, create a variable box of type itemType.  
  • Create a constructor of this class and pass this item as a parameter.
  • Create the getItem method that returns this Box.  

  • Inside the main function create an object of singleItemBox class.  
  • Display the box by calling the getter method.
  • Create an object of singleItemBox class of type string and call the getter method.
You might be interested in
A machine called a centrifuge is used in _____.
Alenkasestr [34]
A machine called a centrifuge is used in many technologies and branches of science, it uses rotary motion to separate material held in suspension from the medium it is suspended in.
7 0
3 years ago
After Alexandra installed new software, she set it up to perform in a certain way. She is _____. changing the peripherals linkin
pashok25 [27]

Answer:

configuring the software

Explanation:

Alexandre is said to have installed a new software to her computer and then proceeds to set it up to perform in a certain way. What she did was to configure the software.

Configuring software in a computer has to do with setting it up to behave in certain ways according to the user.

3 0
3 years ago
g write a recursive function that prints out all the even numbers between x and y inclusive if x is odd then the print out will
Reil [10]

Answer:

The function written in python is as follows:

def EvenNumbers(x, y):

    if (y < x):

         return

    if (y % 2 == 0):

         EvenNumbers(x, y - 2)

    else:

         EvenNumbers(x, y - 1)

    if (y % 2 == 0):

         print(y)

Explanation:

x represents the lower limit while y represents the upper limit.

So, the recursion will be repeated as long as x <= y

This defines the function

def EvenNumbers(x, y):

This checks if y < x. If yes, the recursion stops execution and return to the main

<em>     if (y < x): </em>

<em>          return </em>

The following if and else condition checks determines the appropriate range of the recursion.

<em>     if (y % 2 == 0): </em>

<em>          EvenNumbers(x, y - 2) </em>

<em>     else: </em>

<em>          EvenNumbers(x, y - 1) </em>

The above takes care of printing starting at x + 1 if x is odd

This checks and prints the even numbers in the range

<em>     if (y % 2 == 0): </em>

<em>          print(y)</em>

<em />

To call the function from main, make use of

EvenNumbers(x, y)

Where x and y are integers

e.g EvenNumbers(2,10), EvenNumbers(1,17), EvenNumbers(3,21)

<em>See attachment</em>

3 0
3 years ago
Laptop computers, personal digital assistants, and cellular phones were all readily accepted and diffused in U.S. markets where
astra-53 [7]

Answer: Compatibility

Explanation:

 According to the question, the given products are offering compatibility with the customers needs and the priorities of the consumers. The customers comparability means the degree of the product that fit between customers expectation and the capability of serving by the operation team.

The customers expectation mainly reflected both the present and the past evaluation of the products and the user experience. The compatibility of the customers needs is to meet the quality, value  and the service of the product.

8 0
3 years ago
Individual mental blocks may cause option
Bond [772]

B. negative attitude option

3 0
3 years ago
Other questions:
  • Sam says that when he clicks on his schedule on the Internet, his computer is a receiver, not a sender. Is Sam correct? Why or w
    7·1 answer
  • What is the purpose of a title slide? A) To add titles to each slide B) To introduce the presentation C) To describe the resolut
    12·2 answers
  • HURYY PLEASE and please be the right answer!!!with reasoning
    13·1 answer
  • You turn your computer on and the computer will not boot up where is something you should do to diagnose the problem?
    12·1 answer
  • Which of these is NOT a reason why you would print handouts of your presentation?
    14·1 answer
  • A web feed:
    7·2 answers
  • Which graphic file format is used for commercial purposes.
    10·1 answer
  • You are dropping your friend back home after a night at the movies. From the car, she turns on the indoor lights in her home usi
    9·1 answer
  • Write a code segment that uses a loop to create and place nine labels into a 3-by-3 grid. The text of each label should be its c
    6·1 answer
  • What is the collection of programs designed to operate control and manage the actual operation of the computer equipment​
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!