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
Digital manufacturing has impacted our world today! List a reasons why.
Maru [420]
Because we can get manufacturing faster than usual
6 0
3 years ago
A must decode this code. I guess is not a Cesar. The last line is a email adress.
Pie
It is a text in Polish language.
Powiedz nam w czym jesteś dobry

Magento
Drupal
DjangoSymfony
Python
PHP
Zaznaczone?
Teraz wyślij formularz z konsoli przeglądarki:

require('jquery')[WON'T TRANSLATE THIS LINE BECAUSE IT IS IMMORAL-> YES, I AM A PROGRAMMER :)) ]



3 0
3 years ago
A database stores a large amount data in vertical ___
myrzilka [38]

Records for the first one and table for the second one

4 0
3 years ago
Which technique/concept can be use toimplement multiple inheritances<br> in java?
LiRa [457]

Answer:

Interface

Explanation:

Java does not supports multiple inheritance by class, but we can implement multiple inharitacnce in  java using interface, with interface we uses implements keyword.

Example-

Declare interface like below code -

interface parent{

}

and use in child class like below code -

class Child1 implements interface{

}

class Child2 implements interface{

}

8 0
3 years ago
I know I should add Family and food by default (and I will) But I wanna hear some more from other peoples perspective
lidiya [134]

Answer:

you could say something like your friends or your pets if you have any pets you could say something like you are grateful that we now have 3 vaccines for the Coronavirus or like you are grateful for your hobbies because it gives you something to do in your free time.

Explanation:

i hope this helps.

7 0
3 years ago
Read 2 more answers
Other questions:
  • Which keys should you press to insert a comment? Ctrl+Alt+I Ctrl+Alt+C Ctrl+Alt+O Ctrl+Alt+N Ctrl+Alt+M
    15·1 answer
  • In GamePoints' constructor, assign teamWhales with 500 and teamLions with 500. #include using namespace std; class GamePoints {
    13·1 answer
  • Write a (one) program for your microcontroller so that it:
    14·1 answer
  • What is a googleplex?
    7·1 answer
  • If a memory reference takes 100 nanoseconds, how long does a paged memory reference take?
    6·1 answer
  • /*
    8·1 answer
  • Explain the saying "Dress for the position you want, not the position you have."
    6·2 answers
  • Write a class named Accumulator containing: An instance variable named sum of type integer. A constructor that accepts an intege
    14·1 answer
  • Two technicians are discussing a parasitic load test. Technician A says that the parasitic load is measured with an ammeter Tech
    13·1 answer
  • Zybook C++ 3.21 answer
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!