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
Suppose you have a program P and 90 percent of P can be parallelized, but 10 percent of P is inherently sequential and cannot be
EleoNora [17]

Answer:

Means no matter how many processors you use, speed up never increase from 10 times.

Explanation:

If a problem of size W has a serial component Ws,then performance using parallelism:

Using Amdahl's Law:

Tp = (W - Ws )/ N + Ws

Here, Ws = .1,

W - Ws = .9

Performance Tp = (.9 / N) + .1

---------------------------------------------------------

Speed Up = 1 / ( (.9 / N) + .1)

If N -> infinity, Speed Up <= 10

Means no matter how many processors you use, speed up never increase from 10 times.

5 0
2 years ago
Tabs are usually set ________ to the right of the left margin.
gayaneshka [121]
Ur answer is: a-half-inch
6 0
2 years ago
Read 2 more answers
Josie, your best friend, is having a huge Sweet Sixteen party. She has designated you to address all 100 of the envelopes (using
marysya [2.9K]

You add all the addresses into excel and and do mail-merge with the invitation. Adding the 100 addresses is probably a lengthy process but once this is complete you can just add on addresses and once a year or whenever you have to mail something to everyone, it's  a only mouse-click.

4 0
3 years ago
When you sustain program implementation by staying true to the original design, it is termed A. Goals and objectives B. Program
Naya [18.7K]

Answer:

Program fidelity

Explanation:

7 0
2 years ago
Today's Apple Mac computers run with the same I-Ternal hardware as the Windows based PC true or false
Ksivusya [100]
Kinda of both. The processor, memory, hard drive and displays are all standard components and are provided by a variety computer competent manufacturers (except for the processors which are all supplied by Intel). Yet - while many components are standard - NO, the core, hardware components, like logic boards (motherboard), video cards, and other specialty components (some display connectors and displays, for example) are propriety Apple designs.
5 0
3 years ago
Other questions:
  • A restaurant is a workplace for someone whose career specialty is in
    14·2 answers
  • What is malware short for?
    13·2 answers
  • When we put 10+ points for when we ask a question, do we loose the points we have?
    12·1 answer
  • Choose all of the items that represent functions of the operating system kernel.
    15·2 answers
  • What does cpu stand for
    6·2 answers
  • The data-linking feature that allows Internet users to skip directly from a highlighted word to a related file in another comput
    12·2 answers
  • Using the spreadsheet below, which formula can be used to determine Albert's hourly wage?
    6·2 answers
  • Password is an example of an authentication mechanisms that is based on " what an entity has".
    6·2 answers
  • What is the work of the cpu as processer
    6·2 answers
  • What is the core function of an enterprise platform
    12·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!