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

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 06:50, phillipfruge3
Match the personality traits with their description
Answers: 1
image
Computers and Technology, 23.06.2019 09:30, jason9394
Facial expressions and gestures are examples of messages.
Answers: 3
image
Computers and Technology, 24.06.2019 06:30, hannahgracew12
Some peer-to-peer networks have a server and some don't. true false
Answers: 2
image
Computers and Technology, 24.06.2019 10:40, 29delphina
Joe needs to see the slide transitions and animations he has applied to his slides in a large view. which presentation view should he use? in which tab would joe find the animations option to make further changes, if any?
Answers: 1
You know the right answer?
Public class Road {
private String roadName;
public Road(String name)
{
ro...

Questions in other subjects:

Konu
Spanish, 27.03.2021 04:10
Konu
Mathematics, 27.03.2021 04:10
Konu
Health, 27.03.2021 04:10
Konu
History, 27.03.2021 04:10
Konu
Mathematics, 27.03.2021 04:10