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]
2 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]2 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
Suggest three ways in which celebrating an occasion influences food choices?
Basile [38]

Celebrating influences food in more than 1 way
6 0
2 years ago
Read 2 more answers
Write a (one) program for your microcontroller so that it:
AleksandrR [38]

Answer:

see explaination

Explanation:

1.) Each time the main program execution starts at address 0000 - Reset Vector. The address 0004 is “reserved” for the “interrupt service routine” (ISR).

ORG 0x000 ; processor reset vector

goto main ; go to beginning of main program

ORG 0x004 ; interrupt vector location

movwf w_temp ; save off current W register contents

movf STATUS,w ; move status register into W register

movwf status_temp ; save off contents of STATUS register

.

.

RETFIE

main

3.) Push button switch is connected to the first bit of PORT B (RB0) which is configured as an input pin. When the switch is pressed this pin RB0 will be grounded. The LED is connected to the first bit of PORT B (RA0)

4.) Push button switch is connected to the first bit of PORT B (RB0) which is configured as an input pin. When the switch is pressed this pin RB0 will be grounded. The LED is connected to the first bit of PORT B (RA0)

5.) Push button switch is connected to the first bit of PORT B (RB0) which is configured as an input pin. When the switch is pressed this pin RB0 will be grounded. The LED is connected to the first bit of PORT B (RA0)

#include <stdio.h>

#include <stdlib.h>

#define _XTAL_FREQ 800000//Declare internal OSC Freq as 8MHz

#include <xc.h>

#include<pic.h>

CONFIG(FOSC_INTOSCIO & WDTE_OFF & PWRTE_OFF & MCLRE_ON & BOREN_OFF & LVP_OFF & CPD_OFF & WRT_OFF & CCPMX_RB0 & CP_OFF);

CONFIG(FCMEN_ON & IESO_ON);

unsigned int count=0;

main()

{

TRISA=0;//Sets all ports on A to be outputs

TRISB=1;//Sets all ports on B to be inputs

for(;;){

if(PORTBbits.RB0==1){//When the button is pressed the LED is off

PORTAbits.RA1 =0;

count=count+1;

}

else {

PORTAbits.RA1=1;

count = count +1;

}

if (count > 6){//if count =6 i.e 6 times button presses the RED LED turns on

PORTAbits.RA0=1;

}

else{

PORTAbits.RA0=0;

}

}

}

#include <stdio.h>

#include <stdlib.h>

#define _XTAL_FREQ 800000//Declare internal OSC Freq as 8MHz

#include <xc.h>

#include<pic.h>

CONFIG(FOSC_INTOSCIO & WDTE_OFF & PWRTE_OFF & MCLRE_ON & BOREN_OFF & LVP_OFF & CPD_OFF & WRT_OFF & CCPMX_RB0 & CP_OFF);

CONFIG(FCMEN_ON & IESO_ON);

unsigned int count=0;

main()

{

TRISA=0;//Sets all ports on A to be outputs

TRISB=1;//Sets all ports on B to be inputs

for(;;){

if(PORTBbits.RB0==1){//When the button is pressed the LED is off

PORTAbits.RA1 =0;

count=count+1;

}

else {

PORTAbits.RA1=1;

count = count +1;

}

if (count > 8){//if count =8 i.e 8 times button presses the RED LED turns on

PORTAbits.RA0=1;

}

else{

PORTAbits.RA0=0;

}

}

}

#include <stdio.h>

#include <stdlib.h>

#define _XTAL_FREQ 800000//Declare internal OSC Freq as 8MHz

#include <xc.h>

#include<pic.h>

CONFIG(FOSC_INTOSCIO & WDTE_OFF & PWRTE_OFF & MCLRE_ON & BOREN_OFF & LVP_OFF & CPD_OFF & WRT_OFF & CCPMX_RB0 & CP_OFF);

CONFIG(FCMEN_ON & IESO_ON);

unsigned int count=0;

main()

{

TRISA=0;//Sets all ports on A to be outputs

TRISB=1;//Sets all ports on B to be inputs

for(;;){

if(PORTBbits.RB0==1){//When the button is pressed the LED is off

PORTAbits.RA1 =0;

count=count+1;

}

else {

PORTAbits.RA1=1;

count = count +1;

}

if (count > 10){//if count =10 i.e 10 times button presses the RED LED turns on

PORTAbits.RA0=1;

}

else{

PORTAbits.RA0=0;

}

}

}

6 0
3 years ago
Please help I’ll give brainleistt
iren2701 [21]

Answer:

7. B

8. A

9. B

10. B

11. A

Explanation:

6 0
2 years ago
Dropbox and Microsoft's OneDrive are both popular applications for storing files. What is a fundamental difference between Dropb
Paha777 [63]

The difference is that Dropbox  offers just 2 GB free storage space while  Microsoft's OneDrive gives 5 GB in terms of free storage space.

<h3>What is Microsoft OneDrive?</h3>

This  is known to be a file hosting software and it also does synchronization service given by Microsoft.

Some other  fundamental difference between Dropbox and OneDrive in terms of  Business is that Dropbox is known to often give unlimited storage for about $20 to paid user/month while OneDrive is said to only give unlimited storage for $10 per paid user/month.

Learn more about Dropbox from

brainly.com/question/20935392

5 0
2 years ago
Task queues, which allow for asynchronous performance, are an important part of modern processing architectures. Information abo
Vilka [71]

This subject is a sub-topic in Computer Science and is related to how computers process tasks using Modern Processing Architectures. Modern Processor Architecture is an offshoot of computer architecture.

<h3>What is Modern Processing  Architecture?</h3>

Please note that the information is incomplete hence the general answer. The complete question should provide figures for items 1 to 3.

Modern Processor Architecture is the name given to computer processors with highly advanced capabilities.

In simple language, processors with modern architectures are those that have been built with the ability to complete many instructions or tasks at the same time.

It can also perform or execute these instructions in random order. When a processor is able to do this, it is called Asynchronous performance.

Learn more about Computer Architecture at:

brainly.com/question/18185805

4 0
2 years ago
Other questions:
  • What is word processing and word wrap?
    5·1 answer
  • List the names of 3 computer scientists
    6·2 answers
  • When Russ opened a website on his browser, he saw an error that the site was not compatible with the browser version he was runn
    9·1 answer
  • To add a new kind of information into the database you need to add a new table<br> true or false?
    7·2 answers
  • Which statement describes what this command accomplishes when inside and outside interfaces are correctly identified for NAT? ip
    13·1 answer
  • 8.7 lesson practice question 1
    13·1 answer
  • Lesson 3 - Calling All Operators
    6·1 answer
  • What is technology in computer​
    6·1 answer
  • Examples of structures that can store homogeneous data element​
    14·1 answer
  • Find out about the different technological solutions available for interconnecting LANs to from larger networks such as wide are
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!