Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please privide the answers for each questions. 1. This question is about the cla

ID: 3567587 • Letter: P

Question

Please privide the answers for each questions.

1. This question is about the classes defined in the file Inheritance.java. You can find that file listed below link.

In line 2, an object of class B is assigned to a variable of type A. What is the term for this (two possible choices)?

(file link---> http://cs.kennesaw.edu/~bsetzer/2302fa14/test2-cornflower/inheritance-example.html)

_______________________________

2.This question is also about the classes defined in the file Inheritance.java. In line 3, What is displayed? Which method f is used, the one in line 7 or the one in line 21?

_____________________________

3.This question is about the classes defined in the file Inheritance.java too. What is the term that describes how the system determines which method f is used in the previous part?

_____________________________

4.This question is about the classes defined in the file Inheritance.java too. What is the term that describes the relationship between the two methods named f, the one in line 7 and the one in line 21?

_____________________________

5.This question is about the classes defined in the file Inheritance.java too. What is the term that describes the relationship between the two methods named g, the one in line 11 and the one in line 15?

_____________________________

6.This question is about the classes defined in the file Inheritance.java too. What statement would you add to the method named f in class B(after line 22) that will call the method named f in class A?

_____________________________

7.This question is about the classes defined in the file Inheritance.java too. This question refers to the code for Inheritance.java above. What code would you add to the second method named g in class A(starts on line 15) so that it throws an appropriate exception if the parameter x has a negative value?

_____________________________

8. public double asin() {

   return y / Math.sqrt(x*x+y*y);

}

Add the code to the method asin, above, that will throw an IllegalStateException if the value of x*x+y*y is less than EPS. The exception should include a message that provides the values of x and y, similar to this:

  Point too close to the origin: (1.2E-10, 2.3E-10)

Explanation / Answer

1. Dynamic binding or late binding
2.
f in B is displayed. Line 21 method is executed.

3.
Polymorphism

4.
Method overriding

5.
Method overloading

6.
super.f();

7.
try
{

   throw new Exception("X cannot be negative");
}
catch(Exception e)
{
   //handle exception
}

8.
try{
if( (x*x+y*y) <= 0 )
   throw new IllegalStateException(x + " and "+ y);
}
catch(IllegalStateException e)
{
   //handle exception
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote