1. If class One is extended by class Two, what is the relationship of class One to class Two? (4 points) A class hierarc
Posted: Sat May 14, 2022 7:49 pm
1.
If class One is extended by class Two, what is
the relationship of class One to class Two? (4
points)
A class hierarchy
A derived class
A direct superclass
A subclass
An inherited class
2.
What is the keyword that invokes the constructor of the current
class's parent class? (4 points)
class
extends
private
public
super
3.
Consider the following partial class declarations for
the Triangle and RightTriangle classes:
public class Triangle
{
private int side1, side2,
side3;
public Triangle (int a, int b,
int c)
{
side1
= a;
side2
= b;
side3
= c;
}
// other code not shown
}
public class RightTriangle extends Triangle
{
public RightTriange(int s1, int
s2)
{
<
missing code >
}
// other code not shown
}
What code should replace < missing code >? (4
points)
super();
super(s1, s2);
super(side1, side2, side3);
super(s1, Math.sqrt(Math.pow(s1, 2) + Math.pow(s2, 2)));
super(s1, s2, Math.sqrt(Math.pow(s1, 2) + Math.pow(s2, 2)));
4.
Which of the following statements is true? (4 points)
I only
II only
III only
I and II only
I and III only
5.
Consider the following code:
public class One
{ //implementation
not shown }
public class Two extends
One
{ //implementation
not shown }
public class Three extends
One
{ //implementation
not shown }
Which of the following statements is true? (4 points)
I only
III only
I and II only
I and III only
I, II, and III
If class One is extended by class Two, what is
the relationship of class One to class Two? (4
points)
A class hierarchy
A derived class
A direct superclass
A subclass
An inherited class
2.
What is the keyword that invokes the constructor of the current
class's parent class? (4 points)
class
extends
private
public
super
3.
Consider the following partial class declarations for
the Triangle and RightTriangle classes:
public class Triangle
{
private int side1, side2,
side3;
public Triangle (int a, int b,
int c)
{
side1
= a;
side2
= b;
side3
= c;
}
// other code not shown
}
public class RightTriangle extends Triangle
{
public RightTriange(int s1, int
s2)
{
<
missing code >
}
// other code not shown
}
What code should replace < missing code >? (4
points)
super();
super(s1, s2);
super(side1, side2, side3);
super(s1, Math.sqrt(Math.pow(s1, 2) + Math.pow(s2, 2)));
super(s1, s2, Math.sqrt(Math.pow(s1, 2) + Math.pow(s2, 2)));
4.
Which of the following statements is true? (4 points)
I only
II only
III only
I and II only
I and III only
5.
Consider the following code:
public class One
{ //implementation
not shown }
public class Two extends
One
{ //implementation
not shown }
public class Three extends
One
{ //implementation
not shown }
Which of the following statements is true? (4 points)
I only
III only
I and II only
I and III only
I, II, and III