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
Lorico [155]
3 years ago
13

Write the definition of a class Counter containing: An instance variable named counter of type int. An instance variable named c

ounterID of type int. A static int variable nCounters which is initialized to zero. A constructor that takes an int argument and assigns its value to counter. It also adds one to the static variable nCounters and assigns the result to the instance variable counterID. A method named increment. It does not take parameters or return a value; it just adds one to the instance variable counter. A method named decrement that also doesn't take parameters or return a value; it just subtracts one from the counter. A method named getValue. It returns the value of the instance variable counter. A method named getCounterID: it returns the value of the instance variable counterID.
Computers and Technology
1 answer:
polet [3.4K]3 years ago
4 0
<h2>The definition of a class Counter </h2>

class Counter

{  

Private :                        //access modifier

int counter;                  //defining and initialising variables

int counterID;

static int nCounters=0;

Public :                               //access modifier

Counter(int a)                     //defining functions

{

counter=a;                 //initialising variable counter with argument a          

nCounters++;                   //incrementing 1 to variable nCounters

}

void increment()

{

counter=counter + 1;

}

void decrement()

{

counter=counter - 1;

}

int getValue()

{

return counter;          //returning integer value contained in counter

}

int getCounterID()

{

return counterID;     //returning integer value contained in counter


}

};       //class definition ends





You might be interested in
At what minimum rate is a 60.0-kg boy using energy when, in 8.00 s, he runs up a flight of stairs that is 10.0-m high?
masha68 [24]

The answer is 735 W.

He runs up the stairs, so he needs a total amount of energy = mgh = 5880 Joules. For the rate: since he goes from zero energy to 5880 Joules over 8 seconds... Joules/sec = 5,880/8 = 735 W

5 0
3 years ago
What statement would you use to print the phrase Hello, world and then start a new line?
tangare [24]

Answer:

Statement to print phrase "Hello, world" and then start a new line in java.

System.out.println("Hello, world");

Explanation:

In java, we use "System.out.println();" statement to print any string/phrase and then start a new line.The above line will print phrase "Hello, world" and then start a new line.

Implementation in java:

// class definition

class Main

{

// main method of the class

public static void main (String[] args)

{

// statement to print phrase and start new line

      System.out.println("Hello, world");  

} }

7 0
3 years ago
From an SEO perspective, why is it important to have text alternatives to media items like images, audio, and video?
Ann [662]

Explanation:

This is because the SEO might not be able to access the media items wherever they are, or they could be deleted, or the media items may not be compatible with the SEO. It could also help to have alternatives for accessibility purposes. Therefore, it is important for the SEO to have alternatives to display incase a media item is unable to display for whatever reason.

8 0
2 years ago
Read 2 more answers
Do you think LinkedIn offers an effective way for businesses to market their services? Why or why not?
larisa86 [58]
Yes, because it allows many users to get together and work to help project their services.
5 0
3 years ago
Read 2 more answers
Can u please answer this​
Ivanshal [37]

Answer:

this worksheet can be found online

Explanation:

5 0
2 years ago
Read 2 more answers
Other questions:
  • Designing the moving parts of a car—including the engine, drivetrain, steering, and brakes—is done by what type of engineer?
    11·2 answers
  • What Windows Server 2016 feature leverages the storage contained on a network of servers and adds a new level of fault tolerance
    14·1 answer
  • How would Microsoft Word inform you of the error in the sentence below? (Tip: The error is in bold.)
    7·1 answer
  • Which statement describes borders and shading ?
    13·1 answer
  • Var faceS = 100; var mouthS = 30; ellipse(200, 200, faceS, faceS); ellipse(200, 220, mouthS, mouthS); How wide is the second ell
    12·1 answer
  • How can i promote netiquette??​
    10·1 answer
  • Difference between positional and non positional number​
    12·1 answer
  • How do ice and water on the ground affect incoming solar radiation? They filter 22 percent of solar radiation that reaches the s
    9·2 answers
  • I am doing 7th grade coding 3.02 assignment can anybody help me it says bad input on line 3 and this is what it is can someone h
    6·1 answer
  • Consider sending a stream of packets from host a to host b using ipsec. typically, a new sa will be established for each packet
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!