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]
2 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]2 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
Which of the following statements is not true of web storage?
slavikrds [6]

Answer:

The data in web storage is passed to the server with every HTTP request.

Explanation:

There are basically two Web storage APIs Session storage and local storage.Both can store data up to 5MB. They are supported by every modern browser.You can store data in local storage indefinitely and for browser session in session storage.There is no data or information in HTTP request header.So we conclude that option 4 is the answer.

3 0
2 years ago
Write multiple if statements: If carYear is before 1967, print "Probably has few safety features." (without quotes). If after 19
Liono4ka [1.6K]

Answer:

public class Main

{

public static void main(String[] args) {

    int carYear = 1995;

   

    if(carYear < 1967)

        System.out.println("Probably has few safety features.");

    if(carYear > 1971)

        System.out.println("Probably has head rests.");

    if(carYear > 1992)

        System.out.println("Probably has anti-lock brakes.");

    if(carYear > 2002)

        System.out.println("Probably has tire-pressure monitor.");

   

}

}

Explanation:

The code is in Java.

Initialize the carYear

Use if statements to handle year before 1967, after 1971, after 1992 and after 2002.

Print the required message for each if statement

5 0
3 years ago
I have been trying to use brainly recently but i cant because everytime i watch an ad to get an answer, its an interactive ad, s
Troyanec [42]

Answer:

remove ads

Explanation:

by buying a no ad pack

5 0
2 years ago
Which keyboard shortcut opens the find and replace dialog box to the replace tab?
Vsevolod [243]

Answer:

CTRL + F

Explanation:

usually CTRL + F but it would depend on the program  

3 0
2 years ago
The second version of css, css2, was introduced in 1998, expanding the language to provide styles to _________.
Evgen [1.6K]

Answer:

Structured Documents

Explanation:

Structured Documents consist of hierarchy in the files. They may include data files. HTML (Hyper-text markup language) documents and XML (Extensible Markup Language) applications are the examples of Structured Documents.

6 0
3 years ago
Other questions:
  • Write the pseudocode for linear search, which scans through the sequence, looking for ν. Using a loop invariant, prove that your
    14·1 answer
  • Which option helps you choose the design of a slide in a presentation?
    10·1 answer
  • What test is most similar to binary​
    9·1 answer
  • Which cost of purchasing a franchise would you still have if you start your own business​
    12·1 answer
  • Web crawlers or spiders collect information from Web pages in an automated or semi-automated way. Only the text of Web pages is
    10·1 answer
  • You are utilizing BitLocker Drive Encryption, and are attempting to update Windows Server 2016. What must be done so that the up
    14·1 answer
  • What are the advantages of using digital signals over analog signals? Scientist have found advantages when they convert digital
    5·2 answers
  • To discover how many cells in a range contain values that meet a single criterion, use the ___ function
    5·1 answer
  • Retype the paragraph with the corrections. There are 12 corrections. Look closely at the word and letter highlighted in yellow t
    9·1 answer
  • What is the purpose of a hyperlink in a presentation?
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!