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
xeze [42]
3 years ago
15

What is the output of this code? import java.util.HashSet; class A { public static void main(String[ ] args) { HashSet set = new

HashSet(); set.add("A"); set.add("B"); set.add("C"); System.out.println(set.size()); } }
Computers and Technology
1 answer:
kompoz [17]3 years ago
5 0

Answer:

The code will give an error that is "At least one public class is required in main file".

Explanation:

In the given code if we do not use the public access modifier to the class. It will give an error so, the correct code to this question as follows:

Program:

import java.util.HashSet; //import package

public class A  //define class as public.

{

   public static void main(String[ ] args) //define main method.

   {

       HashSet set = new HashSet(); //creating hashset object.

       set.add("A"); //add alphabet in hashset

       set.add("B"); //add alphabet in hashset

       set.add("C"); //add alphabet in hashset

       System.out.print("Size of HashSet is :"set.size()); //print the size of hashset.

   }

}

Output:

Size of HashSet is : 3

Explanation of the program:  

  • In the above program, we define a public class that is "A" and inside the class, we define the main method.  
  • Inside the main method, we create a HashSet class object that is "set".  
  • To add elements in HashSet we use add() function that adds elements and in the last, we use the size() function that prints the size HashSet.
You might be interested in
Write at leaat 20 shortcuts on the Microsoft word.​
Flauer [41]

Answer:

Open a document: Ctrl + O.

Create a new document: Ctrl + N.

Save the current document: Ctrl + S.

Open the Save As window: F12.

Close the current document: Ctrl + W.

Split the window: Alt + Ctrl + S.

Copy: Ctrl+C

Paste: Ctrl+V

Cut the current selection: Ctrl + X

Copy the current selection: Ctrl + C

Paste the contents of the clipboard: Ctrl + V

Bold: Ctrl + B

Italics: Ctrl + I

Underline: Ctrl + U

Underline words only: Ctrl + Shift + W

Center: Ctrl + E

Make the font smaller: Ctrl + [

Make the font bigger: Ctrl + ]

Change text to uppercase: Ctrl + Shift + A

Change text to lowercase: Ctrl + Shift K

Insert a page break: Ctrl + Enter

Add a hyperlink: Ctrl + K

Explanation:

3 0
3 years ago
Using C++, complete function PrintPopcornTime(), with int parameter bagOunces, and void return type. If bagOunces is less than 2
victus00 [196]

Answer:

#include <iostream>

using namespace std;

void PrintPopcornTime(int bagOunces) {

   if(bagOunces < 2)

       cout << "Too small" << endl;

   else if(bagOunces > 10)

       cout << "Too large" << endl;

   else

       cout << 6 * bagOunces <<" seconds" << endl;

}

int main()

{

   int userOunces;

   cin >> userOunces;

   PrintPopcornTime(userOunces);

   return 0;

}

Explanation:

Inside the function PrintPopcornTime, check the parameter bagOunces using if structure. Depending on the value of bagOunces, print the required information.

Inside the main, ask the user for the userOunces. Call the PrintPopcornTime function with the userOunces.

3 0
3 years ago
List at least five tasks a layer performs. Could one (or more) of these tasks could be performed by multiple layers?
ludmilkaskok [199]

Answer:

Transport layer:

- data packets are segment to smaller chunks.

- gives sequence number to segment.

- identifies the source and destination port number.

- initiates data transmission between nodes.

- rearrange and identifies the application, the transmitted data is meant for.

Explanation:

The transport layer is the fourth layer in the OSI network model. Protocols like TCP and UDP are found in this layer. It segment data packets and for a connection oriented protocol like TCP, it creates an established session between source and destination host (the session layer can also do this, but it is more defined in the transport layer).

The network and data-link layer can also transmit data packets.

6 0
3 years ago
In Hootsuite Inbox, you can see all the correspondence between a user and your organization on a particular social channel, incl
VARVARA [1.3K]

The ability to view all the correspondence between an end user and your organization (company) on a particular social media channel, as well as public and private conversations is useful for understanding the full context of the most recent exchange in Hootsuite Inbox.

<h3>What is Hootsuite Inbox?</h3>

Hootsuite Inbox can be defined as a type of software application that is designed and developed to help end users in managing social messages (correspondence) from their organization's customers and audiences, especially by availing them an ability to collect and view (see) both private and public conversations (messages) from all networks or social media channel in one place.

This ultimately implies that, the ability to view all the correspondence between an end user and your organization (company) on a particular social media channel, as well as public and private conversations is useful for understanding the full context of the most recent exchange in Hootsuite Inbox.

Read more on Hootsuite Inbox here: brainly.com/question/15321261

#SPJ1

3 0
2 years ago
He said,'I am learning French these days' convert to indirect Speech​
Paha777 [63]

Answer:

Indirectl Speech:

He said that he is learning French these days•

4 0
3 years ago
Other questions:
  • Windows Hello supports multiple biometric authentication methods, including facial recognition. What is the failsafe method to a
    6·1 answer
  • How can you achieve an effect like that shown in the image
    6·2 answers
  • (Statistics) Write a program that includes two functions named calcavg() and variance(). The calcavg() function should calculate
    10·1 answer
  • Its Inventiveness, uncertainty and futuristic ideas typically deals with science technology, what is it?
    7·2 answers
  • 1.       An ________ works for a company to design, carry out, and solve its electronic equipment related problems.
    11·1 answer
  • Write a program that takes an integer n as a parameter and sums all of the multiples of 2 or 5 from 1 to n. For example, if n =
    14·1 answer
  • Which of the following code is correct? I: print("Programming is fun") print("Python") print("Computer Science") II: print("Prog
    11·1 answer
  • What is software piracy?
    11·1 answer
  • 3) How ash traditional technology and modern
    10·1 answer
  • You have implemented an access control method that only allows users who are managers to access specific data. Which type of acc
    11·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!