subject

Public class Road {
private String roadName;
public Road(String name)
{
roadName = name;
}
}
public class Highway extends Road
{
private int speedLimit;
public Highway(String name, int limit)
{
super(name);
speedLimit = limit;
}
}
The following code segment appears in a method in another class.
Road r1 = new Highway("Interstate 101", 55); // line 1
Road r2 = new Road("Elm Street"); // line 2
Highway r3 = new Road("Sullivan Street"); // line 3
Highway r4 = new Highway("New Jersey Turnpike", 65); // line 4
Which of the following best explains the error, if any, in the code segment?
A) Line 1 will cause an error because a Road variable cannot be instantiated as an object of type Highway.
B) Line 2 will cause an error because the Road constructor is not properly called.
C) Line 3 will cause an error because a Highway variable cannot be instantiated as an object of type Road.
D) Line 4 will cause an error because the Highway constructor is not properly called.
E) The code segment compiles and runs without error.

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 11:00
When working with a team you should always do the following, except? question 3 options: be dependable and trustworthy be sensitive to others feelings do your fair share critique members of the group
Answers: 2
question
Computers and Technology, 22.06.2019 21:00
Write a method so that the main() code below can be replaced by the simpler code that calls method original main(): public class calcmiles { public static void main(string [] args) { double milesperhour; double minutestraveled; double hourstraveled; double milestraveled; milesprhour = scnr.nextdouble(); minutestraveled = scnr.nextdouble(); hourstraveled = minutestraveled / 60.0; milestraveled = hourstraveled * milesperhour; system.out.println("miles: " + milestraveled); } }
Answers: 2
question
Computers and Technology, 22.06.2019 23:00
Is an attack that relies on guessing the isns of tcp packets
Answers: 2
question
Computers and Technology, 23.06.2019 07:00
You need a quick answer from a coworker. the most effective way to reach your coworker is through a. cloud server b. instant message c. teleconference d. telepresence
Answers: 1
You know the right answer?
Public class Road {
private String roadName;
public Road(String name)
{
ro...
Questions
question
Mathematics, 18.12.2020 17:30
question
Business, 18.12.2020 17:30
question
Computers and Technology, 18.12.2020 17:30
question
Mathematics, 18.12.2020 17:30
question
Biology, 18.12.2020 17:30
Questions on the website: 13722361