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
Fill in the blanks:In the context of cyber security, social engineering (SE) is a deceptive practice that exploits human _______
lord [1]

Answer:

In the context of cyber security, social engineering (SE) is a deceptive practice that exploits human <u>weaknesses </u>  by inducing victims to interact with a digital device in a way that is not in their best interest. Many of these attacks begin with<u> spam</u> , which is defined as unsolicited messages that are usually sent in massive numbers using electronic mail systems. A spam  <u>filter</u> uses a set of rules to examine email messages and determine which are spam. There are four common types of spam filters.<u> Content  </u>filters examine the content within a message for certain words or phrases commonly used in spam emails.<u> Header</u> filters review the email header for falsified information, such as spoofed IP addresses. <u>Blacklist</u> filters block mail that originates from IP addresses of known spammers. <u>Permission </u>                    filters block or allow mail based on the sender's address. <u>Phishing</u> is an email scam that masquerades as a message from a(n) legitimate company or agency of authority, such as the IRS. <u>Pharming</u> redirects Web site traffic to fraudulent Web sites that distribute malware, collect personal data, sell counterfeit products, and perpetrate other scams. A rogue <u>antivirus </u>                exploit usually begins with a virus warning and an offer to disinfect the infected device. Some software is not exactly malware, but it is a nuisance. A <u>PUA </u>takes up residence on a digital device and seems impossible to disable or remove.

3 0
3 years ago
Have you been tempted to do something online that you wouldn't do if<br> people knew it was you?
Aleksandr-060686 [28]

Answer

I don't know tbh, Maybe once or twice here or there.

Explanation:

6 0
3 years ago
1) "Information systems are revolutionizing the way businesses function in the 21st century," Do you agree or disagree with this
alukav5142 [94]

Answer:

true

Explanation:

everything is computerized. banks, shopping, financial business records, ect

7 0
3 years ago
Brianna is a multimedia specialist who works for a large fast food chain. What task
Tju [1.3M]

Answer:

Recording and publishing training videos for new employees

Explanation:

Multimedia specialists design and create IT-based multimedia products such as websites, DVDs, and computer games that combine text with sounds, pictures, graphics, video-clips, virtual reality and digital animation

4 0
3 years ago
Describe the technology used in space exploration
OverLord2011 [107]
The technology used in space exploration are simple observation technologies such as cameras, recorders and other machines to study a certain place in the space. Also space exploration needs survival technology for the spacemen allowing them to survive for many many years.
5 0
3 years ago
Read 2 more answers
Other questions:
  • write a 〕ava program to sort a random list of 10 numbers entered b y user in an array using Selection Sort technique
    5·1 answer
  • Assume that scotus is a two-dimensional character array that stores the family names (last names ) of the nine justices on the S
    6·1 answer
  • After reviewing the various types of network connections available, a client chooses a network connection that is considered to
    13·1 answer
  • Choose the reasons why Windows Server operating systems are a popular choice for a network because they _____. Select all that a
    12·1 answer
  • Discuss FOUR challenges that have an impact on domestic tourism
    6·1 answer
  • ¿dispositivos de hardware Que permite identificar la huella digital registrada por el usuario?
    11·1 answer
  • True/False: The American Standard Code for Information (ASCII) is a code that allows people to read information on a computer.
    9·2 answers
  • Which of the following is an example of joint problem solving?
    12·1 answer
  • Write a python program to calculate the average of two numbers​
    8·1 answer
  • Explain with examples: <br> What are the reasons of a successful and unsuccessful software project?
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!