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
sertanlavr [38]
3 years ago
5

Write the definition of a class Counter containing:

Computers and Technology
1 answer:
Dmitriy789 [7]3 years ago
4 0

Answer:

Answer is in java language.

Explanation:

Java Code

a) Creating instance variable

public class Counter {

   int counter;

   int limit;

}

Code Explanation

create a public class and declare variables inside the class block. By doing this, it will create instance variable of that class.

b) Constructor

public Counter(int first, int second){

       this.counter=first;

       this.limit=second;

   }

Code Explanation

Constructor are method having no return type and having exact name as Class name. Constructor are used to initialize the class instance before calling any other method.

c) Increment Method

public void increment(){

       if(this.counter<this.limit){

           counter++;

       }

   }

Code Explanation

void tells the compiler that there is nothing to return from current method. If block is checking the condition that if counter is less then the limit then increment the counter by 1.

d) Decrements Method

public void decrement(){

       if(this.counter>0){

           this.counter--;

       }

   }

Code Explanation

Decrement method will check if counter value is greater then 0 then decrement counter value by 1 in if block.

e) getValue method

public int getValue(){

       return this.counter;

   }

Code Explanation

getValue method will take no parameter as input and return the current counter value by using return statement.

Full Code Example

public class Counter {

   int counter;

   int limit;

   public Counter(int first, int second){

       this.counter=first;

       this.limit=second;

   }

   public void increment(){

       if(this.counter<this.limit){

           counter++;

       }

   }

   public void decrement(){

       if(this.counter>0){

           this.counter--;

       }

   }

public int getValue(){

       return this.counter;

   }

}

You might be interested in
You are the security administrator for a bank. The users are complaining about the network being slow. It is not a particularly
bulgar [2K]

Answer:Denial of service

Explanation:Denial of service is the type of attack that is caused to the computer attacks. These attacks basically cause the circumstances such as difficulty in accessing of the website or resource, accessing particular computer system , creation of the traffic in network, This attack occurrence stops or create difficulties for the legal person to access the network .

Therefore, there is the occurrence of the Denial of service(DoS) in the bank's computer network.

3 0
3 years ago
How do you make a photo the background on microsoft powerpoint?
Anna35 [415]
Well it is a very simple process all you do is open adobe photoshop and then put your picture in there then you go to your power point and go to file then new go to custom background got to photoshop chance the dimensions to your liking and boom done 
4 0
3 years ago
Fill in the blanks:In the context of cyber security, social engineering (SE) is a deceptive practice that exploits human _______
lord [1]

Answer:

In the context of cyber security, social engineering (SE) is a deceptive practice that exploits human <u>weaknesses </u>  by inducing victims to interact with a digital device in a way that is not in their best interest. Many of these attacks begin with<u> spam</u> , which is defined as unsolicited messages that are usually sent in massive numbers using electronic mail systems. A spam  <u>filter</u> uses a set of rules to examine email messages and determine which are spam. There are four common types of spam filters.<u> Content  </u>filters examine the content within a message for certain words or phrases commonly used in spam emails.<u> Header</u> filters review the email header for falsified information, such as spoofed IP addresses. <u>Blacklist</u> filters block mail that originates from IP addresses of known spammers. <u>Permission </u>                    filters block or allow mail based on the sender's address. <u>Phishing</u> is an email scam that masquerades as a message from a(n) legitimate company or agency of authority, such as the IRS. <u>Pharming</u> redirects Web site traffic to fraudulent Web sites that distribute malware, collect personal data, sell counterfeit products, and perpetrate other scams. A rogue <u>antivirus </u>                exploit usually begins with a virus warning and an offer to disinfect the infected device. Some software is not exactly malware, but it is a nuisance. A <u>PUA </u>takes up residence on a digital device and seems impossible to disable or remove.

3 0
3 years ago
Which magazine can help public determine best technology to buy
Dennis_Churaev [7]
Consumer report would help determine the best technology to buy.
4 0
3 years ago
Does ripping a dvd erase the original content
kap26 [50]
No, ripping is the process of reading all content in order to make a copy. Nothing is erased.
7 0
3 years ago
Other questions:
  • In traditional programming, probably the most often used error-handling outcome was to ____.
    15·1 answer
  • When you use file explorer or windows explorer to delete a file from the hard drive, where does windows put the file?
    11·1 answer
  • 3. (20 points) Write a C++ recursive function that finds the maximum value in an array (or vector) of integers without using any
    9·1 answer
  • Example of a question that could NOT be answered with a binary message
    10·2 answers
  • _____ is a software delivery approach in which an organization outsources the equipment used to support its data processing oper
    5·1 answer
  • A (an) block can arise from set ways of thinking.
    15·1 answer
  • NEED HELP WILL MARK BRAINLIEST AND 100 POINTS FOR ANSWER Which LIKE operator would match a single character?
    9·2 answers
  • Anybody got a quisten
    12·1 answer
  • how to make windows laptop work faster because I mine is so slowwwww. I already updated it and everything and tried everything b
    9·1 answer
  • Purchase computing resources as an outsourced service from suppliers who own and maintain all the necessary equipment and softwa
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!