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
There are several methods of updating information and data on a webserver. We must consider who performs those updates upfront w
Thepotemich [5.8K]

Answer:

RTMC pro, HTML server-sent and Java Software Development Kit

Explanation:

<u>RTMC pro</u>:  The setup of RTMC pro is done automatically and there is provision of several elements to upload and store data on the server using screens. Screens are usually saved as files and then integrated to an internal or external server.

<u>HTML server-sent</u> : This is a way for webpages to communicate with the webserver. In this method, for ever HTML page there is an associated script present on the server side that will continuously provide realtime data update. This scrip will have to be configured with the data you want to update.

<u>Java Software Development Kit</u> : JAVA SDK is used to build software/applications on Java. This permits programmers to develop applications or applets to perform data updating on the servers. The developped applets can be used with internal servers as well as third party servers.

5 0
3 years ago
Read 2 more answers
Which of the following statements best compares and contrasts the role of story writers and script writers
Citrus2011 [14]

Answer:

Both script and story writers must use the elements of plot to develop their work; however, script writers must also include the use of stage and camera descriptions.

Explanation:

7 0
3 years ago
You have a multi-domain Windows Server 2008 forest. You need to make a shared folder available to users from several domains. Wh
mihalych1998 [28]
I thick is C domain local
5 0
3 years ago
What is the output of the following code? public class Test { public static void main(String[] args) { String s1 = new String("J
Darya [45]

Answer:

false true

Explanation:

In the code snippet, two string objects are created in java with the value Java.

The print method first checks the condition s1==s2 and outputs false, This is so because the operator == which is used for equality in other primitive data types like ints cannot be applied to the String data type. In the second part of the print function, the equals function s1.equals(s2) is used and it prints true since the two string are equal

6 0
3 years ago
If someone said to you, “Pseudocode is a waste of time! It’s just more work because you end up writing the same program twice,”
myrzilka [38]

Answer:

It allows the designer to focus on main logic without being distracted by programming languages syntax.

* Since it is language independent, it can be translated to any computer language code.

* It allows designer to express logic in plain natural language.

* It is easier to write actual code using pseudocode.

* Unlike algorithms, pseudocodes are concise so pseudocodes are more readable and easier to modify.

Explanation:

8 0
3 years ago
Other questions:
  • Suppose the program counter (pc) is set to 0x2000 0000. is it possible to use the jump (j) mips assembly instruction to set the
    15·1 answer
  • Which strategy are you using when you only read the title, section headings, and captions?
    12·2 answers
  • In which career field would the computing technology industry associations compTIA A+ certification be useful
    6·1 answer
  • Write a program whose input is a character and a string, and whose output indicates the number of times the character appears in
    11·1 answer
  • Given two variables , first_place_winner and second_place_winner, write some code that swaps their associated values. use any ad
    12·1 answer
  • A company accidentally sends a newsletter with a mistyped website address. The address points to a website that has been spoofed
    8·1 answer
  • A subroutine may be used to refer to which of the following? Check all that apply.
    15·2 answers
  • <br> Help me please I need the correct answe
    10·1 answer
  • When an external device becomes ready to be serviced by the processor the device sends a(n)_________ signal to the processor.
    8·1 answer
  • You would like to see only the last 15 lines of /home/user/log file on your linux machine. Which command line interface (cli) co
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!