Question: Explain the difference between an is - a and has - a relationship in Java. public class Example { public static void

Explain the difference between an "is-a" and "has-a" relationship in Java.
public class Example { public static void main(String[] args){ double a =1.3; double b=2; double total = calc(b, a); System.out.println("the total is "+ total); } public static double calc(double c, double d){ return (c - d); }}
1. What are the names of the formal parameters for method calc in the above class?
2. Do you find actual parameters in the method definition or method invocation?
3. What is the method signature of method calc?
4. What is the method header of method calc?
5. Is the static keyword required here in the declaration of the calc method? Why or why not?
Provide an example of each concept to further demonstrate your understanding. (no code is required for this question, but feel free to use code if it helps your explanation)
Answer text Question 1
Rich text editor
Question 15Answer
a.
private methods
b.
public methods
c.
protected methods
d.
a and b
e.
b and c
Question 14Answer
a.
the parameter list and method name
b.
the parameter list
c.
the method name
d.
return type, method name, and parameter list
Question 13Answer
a.
x contains a reference to a Circle object.
b.
x contains an object of the Circle type.
c.
You can assign an int value to x.
d.
x contains an int value.
Question 12Answer
a.
that a variable of supertype can refer to a subtype object
b.
none of the above
c.
that a class can contain another class
d.
that data fields should be declared private
Question 11Answer
a.
Raptor object can refer to a Lightning object
b.
FighterJet object can not refer to a Lightning object
c.
Lightning object can refer to a Raptor object
d.
FighterJet object can refer to a Raptor object
Question 10Answer
a.
Subclass is more detailed than the superclass
b.
Superclass is more detailed than the subclass
c.
Subclass and superclass are only related through composition
d.
Both the subclass and superclass have the same level of detail

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!