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
iogann1982 [59]
4 years ago
12

Write a class definition of a class named Value with the following: a boolean instance variable named modified, initialized to f

alse an int instance variable named val a constructor accepting a single parameter whose value is assigned to the instance variable val a method getVal that returns the current value of the instance variable val a method setVal that accepts a single parameter, assigns its value to val, and sets the modified instance variable to true a boolean method, wasModified that returns true if setVal was ever called.
Computers and Technology
1 answer:
densk [106]4 years ago
3 0

Answer:

The class definition to this question can be given as:

Class definition:

public class Value //define class value.  

{  

private boolean modified = false; //define variable modified.  

private int val; //define variable.

Value(int i) //parameterized constructor

{

val = i; //holds parameter value.  

}  

public int getVal() //define method getVal.

{

return val;  

}  

public void setVal(int i) //define method setVal

{

val = i; //holds parameter value

modified = true; //change boolean variable value.  

}  

public boolean wasModified() //define method wasModified.

{

return modified; //return value.

}  

}

Explanation:

The description of the above class definition as follows:

  • Firstly we define a class that is "value" inside a class we define two variable that is "modified and val". Where modified is a boolean variable that holds boolean value true or false and val is an integer variable that holds an integer value.  
  • Inside the class, we define parameterized constructor in this constructor we pass an integer parameter that is "i" inside this constructor we use the val variable for hold i variable value.
  • Then we define three functions that are "getVal, setVal, and wasModified".  
  • The getVal() function is used for return value.  The setVal() function uses an integer parameter that is "i" this function holds value in variable i in val variable and change value of the modified variable that is "true".  The wasModified() function is used to return modified variable value.

You might be interested in
Using the XML Document below (library with books), define the following queries in XQuery: (a) Give the titles of all Books sort
Softa [21]

Answer:

Explanation:

a)use order by clause for sorting

for $x in doc("books.xml")/bib/book order by xs:float($x/price) return $x/title (default sorted in ascending order)

or

for $x in doc("books.xml")/bib/book order by xs:float($b/price) descending  return $b/title (sorted in descending order)

b)doc("books.xml")//book[author = 'Abiteboul']

c)for $x in distinct-values(doc("bib.xml")/bib/book/author)

return <res>

<name>{$x}</name>

<count>

 {count (doc("bib.xml")//book[exists(indexof(author,$x))]) }

</count>

<res>

3 0
3 years ago
What console can be used to enable disable start or stop a service
umka21 [38]
That would be msconfig!
5 0
3 years ago
A computer retail store has 15 personal computers in stock. A buyer wants to purchase 3 of them. Unknown to either the retail st
Dima020 [189]

Answer:

a. 1365 ways

b. Probability = 0.4096

c. Probability = 0.5904

Explanation:

Given

PCs = 15

Purchase = 3

Solving (a): Ways to select 4 computers out of 15, we make use of Combination formula as follows;

^nC_r = \frac{n!}{(n-r)!r!}

Where n = 15\ and\ r = 4

^{15}C_4 = \frac{15!}{(15-4)!4!}

^{15}C_4 = \frac{15!}{11!4!}

^{15}C_4 = \frac{15 * 14 * 13 * 12 * 11!}{11! * 4 * 3 * 2 * 1}

^{15}C_4 = \frac{15 * 14 * 13 * 12}{4 * 3 * 2 * 1}

^{15}C_4 = \frac{32760}{24}

^{15}C_4 = 1365

<em>Hence, there are 1365 ways </em>

Solving (b): The probability that exactly 1 will be defective (from the selected 4)

First, we calculate the probability of a PC being defective (p) and probability of a PC not being defective (q)

<em>From the given parameters; 3 out of 15 is detective;</em>

So;

p = 3/15

p = 0.2

q = 1 - p

q = 1 - 0.2

q = 0.8

Solving further using binomial;

(p + q)^n = p^n + ^nC_1p^{n-1}q + ^nC_2p^{n-2}q^2 + .....+q^n

Where n = 4

For the probability that exactly 1 out of 4 will be defective, we make use of

Probability =  ^nC_3pq^3

Substitute 4 for n, 0.2 for p and 0.8 for q

Probability =  ^4C_3 * 0.2 * 0.8^3

Probability =  \frac{4!}{3!1!} * 0.2 * 0.8^3

Probability = 4 * 0.2 * 0.8^3

Probability = 0.4096

Solving (c): Probability that at least one is defective;

In probability, opposite probability sums to 1;

Hence;

<em>Probability that at least one is defective + Probability that at none is defective = 1</em>

Probability that none is defective is calculated as thus;

Probability =  q^n

Substitute 4 for n and 0.8 for q

Probability =  0.8^4

Probability = 0.4096

Substitute 0.4096 for Probability that at none is defective

Probability that at least one is defective + 0.4096= 1

Collect Like Terms

Probability = 1 - 0.4096

Probability = 0.5904

8 0
3 years ago
Which of the following cools the air in a household refrigerator?
Ivanshal [37]

The following cools the air in a household refrigerator: Absorption of the heat from the air due to evaporation of the liquid refrigerant . Correct answer:B

The function of the refrigerator is to absorb heat into the refrigeration system. The evaporator is placed in the area to be cooled. The refrigerant vaporizes from the heat it absorbs heat in the evaporator.

4 0
3 years ago
Read 2 more answers
What will be printed when the method printstuff is called?
abruzzese [7]
Here is the correct answer of the given question above. The one that will be printed when the method printstuff is called is that there will be a compile error because a double cannot be assigned to an int <span>without a cast. Hope this answer helps. </span>
3 0
4 years ago
Other questions:
  • Which sparkline type is best for displaying trends in data changes over time?
    11·1 answer
  • A network ____ usually contains a computer, networked peripheral, or network device.
    14·1 answer
  • In the range C15:G15, insert a function to calculate the total daily revenue. In the range H11:H15, insert a function to calcula
    8·1 answer
  • The measure of the maximum amount of data that can travel through a computer’s communications path in a given amount of time is
    9·1 answer
  • 7. When using find command in word we can search?
    7·1 answer
  • (15 POINTS) When an error is made in HTML code, the browser does what?
    11·1 answer
  • I need help ASAP Please! :)
    5·1 answer
  • When replacing a system board in a laptop, which feature is a must?
    7·1 answer
  • Why can videos be streamed from the cloud to a computer with no loss in
    5·2 answers
  • You will need to convert the following binary numbers to hexadecimal. Table 1 contains 16 problems. The first one is completed f
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!