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
Temka [501]
4 years ago
7

Write a custom exception class called ParameterNotAllowedException that contains the following: 1. An integer instance variable

representing the input number that went wrong. 2. A two parameter constructor that accepts a message and an integer, This constructor should copy the integer parameter into the instance variable and call the Exception class's one parameter constructor. 3. An overidden getMessage() method that returns a message explaining that the integer is invalid.
Computers and Technology
1 answer:
jeyben [28]4 years ago
7 0

Answer:

See explaination

Explanation:

//class extends Exception

class ParameterNotAllowedException extends Exception {

//Instance variable

private int input;

//Argumented constructor

public ParameterNotAllowedException(String message, int input) {

super(message);

this.input = input;

}

public int getInput() {

return input;

}

public void setInput(int input) {

this.input = input;

}

atOverride // Replace the "at" with at symbol ie shift 2

public String getMessage() {

//Returns the message

return input+" is invalid. "+super.getMessage();

}

}

class Main {

public static void main(String[] args) throws ParameterNotAllowedException {

int n = -1;

//Throw negative not allowed exception

if(n<0){

throw new ParameterNotAllowedException("negative number",n);

}

}

}

You might be interested in
A device that filters data traffic at a network boundary​
Semmy [17]

Answer:

Bridges

Explanation:

A bridge is a transition effects that separates network traffic at the network's edge. By splitting a local area network into two parts, bridges minimise the number of bandwidth.

6 0
3 years ago
John would like to move from the suburbs into the city, but the rent in the city is very high. John has found an apartment he re
maxonik [38]

A list of multiple choices is given;

<span>a)      </span>Purchase a home in the city center instead.

<span>b)      </span>Rent the apartment anyway.

<span>c)       </span>Rent the apartment with a roommate.

<span>d)      </span>Purchase a home in the suburbs instead.


The answer is (C)


John should look for an apartment and share it with a roommate. This will bring down rent expenses to 50% as both John and the roommate will be cost sharing the rent. If the rent expenses go down by 50%, he’ll be able to save an additional 10% and use it for other expenses.

4 0
3 years ago
Is it possible to do Agile project in Waterfall methodology?
MariettaO [177]
Yes, it could be possilbe
5 0
3 years ago
Read 2 more answers
Write a Java method to delete a record from a B-tree of order n.
max2010maxim [7]

Answer:

Deleting a record on a B-tree consists of three main events:

- Searching the node where the key to be deleted exists

- Deleting the key

- Balancing the tree if required

Explanation:

q = NULL;

   p = tree;

   while (p) {

       i = nodesearch(p, key);

       q = p;

       if (i < used(p) -1 && key == k(p,i)) {

           found = TRUE;

           position = i;

           break;

       }

       p = son(p,i);

   }

   if (!found)

   else if (subtree(p)) {

         if (used(p) > ((n-1)/2)+1)

         delkey (p, position, key);

       else {

           replace (p, position, fsucc(p));

           p0 r1 p1 r2 p2 r3 ……. pn-1 rn-1 pn

           q = &fsucc(p);

           qpos = index of fsucc;

           if (used(rbrother(p)) > ((n-1)/2)+1)

               replace (q, qpos, sonsucc(q));

           else

               while (q && used(q) < (n-1)/2) {

                   concatenate(q, brother(q));

                   q = father(q);

               }

       }

   }

   else

   delkey(p, position, key);

}

6 0
3 years ago
Email Communication has it own set of etiquette guidelines for users to follow if they want to be effective communicators. Which
Olin [163]
You answer is most likely D.
5 0
3 years ago
Other questions:
  • 3k means about 3 thousand bytes. how would you express two hundred million bytes?
    8·1 answer
  • Presentation software allows business professionals to _____.
    14·2 answers
  • Identify the six components of an information system. Which are most directly affected by the study of computer security? Which
    8·1 answer
  • It is important to ____ the line in the code editing window in the exact location where you want to insert a code snippet to pro
    10·1 answer
  • Optimizing a PC’s performance often involves utilities that can defragment disks, clean a system’s Registry, scan for malware, r
    14·1 answer
  • Which of the following lists the proper order of the categories of the SOC system from general to specific?
    11·1 answer
  • Mô tả những lợi ích của việc sử dụng đa xử lý không đồng nhất trong một hệ thống di động
    8·1 answer
  • which of the following can be represented by a sequence of bits. 1. An integer 2. An alphanumeric character 3. A machine languag
    12·1 answer
  • Suppose you are working as an administrative assistant at a small law firm. Your boss has asked you to send an invitation out to
    5·1 answer
  • An epic games service is unavailable at the moment
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!