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
Java uses a right brace to mark the end of all compound statements. What are the arguments for and against this design?
Vlada [557]

Explanation:

The argument is for the right braces.The right braces are used for simplicity.The right brace always terminates a block of code or a function.

The argument against right brace is that when we see a right brace in a program,we are not obvious about the location of the corresponding left brace because all or multiple  statement end with a right brace.

7 0
3 years ago
With the Linux operating system, its open source design means it can be used, modified and ______
nadya68 [22]

Answer:

distributed.

Explanation:

Because Linux is released under an open source license, which prevents restrictions on the use of the software, anyone can run, study, modify, and redistribute the source code, or even sell copies of their modified code, as long as they do so under the same license.

3 0
3 years ago
Which of the following statements are true about mobile app development? Select 3 options.
mestny [16]

Answer:

Option 1,4 and 5 are correct.

7 0
3 years ago
Read 2 more answers
When using a presentation software you can change the size of the text to...? Increase Font size, Decrease font size, increase t
ira [324]
Increase font size/ Decrease font size
7 0
3 years ago
Read 2 more answers
How will you be assigned with a mailbox with any OSP
Leona [35]

Answer:

Go to the File tab and click Options.

Click on the Mail menu at the left.

Click on the Signatures button to open the Signatures and Stationary window.

In the Email Signature tab, click New.

Type in a name for the New Signature such as Shared Mailbox Signature and click OK.

Explanation:

3 0
3 years ago
Other questions:
  • How does a combustion engine works?
    7·2 answers
  • Sending packets with false ip source addresses is called ____. ip address spoofing a port scanning attack a ip address scanning
    11·1 answer
  • Choose the reasons why Windows Server operating systems are a popular choice for a network because they _____. Select all that a
    12·1 answer
  • I just downloaded an update for my laptop. Now, it doesn't give me a notification when the battery is low, and it just shuts off
    6·1 answer
  • Write a program which capitalize every character after full stopin a given sentence
    11·1 answer
  • Arrange these steps of creating a presentation in the correct order.
    15·2 answers
  • Which of the following is an upper body workout
    6·2 answers
  • Write a summary on the video "Greatest Inventions w/Bill Nye".
    10·1 answer
  • Voice of the customer, Social Media Analytics, churn analysis, survey analysis, and market research analytics are more likely to
    13·1 answer
  • Some operating systems add the command interpreter to the kernel .what will be the justification for this design principle?
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!