Page 1 of 1

Given the definition of the Vehicle class:Class Vehicle {int distance;Vehicle (int x) {this distance = x;}public void in

Posted: Sun Jun 11, 2023 4:01 pm
by answerhappygod
Given the definition of the Vehicle class:Class Vehicle {int distance;Vehicle (int x) {this distance = x;}public void increSpeed(int time) {int timeTravel = time; //line n1//line n3class Car {int value = 0;public void speed () {value = distance /timeTravel; //line n2System.out.println ("Velocity with new speed"+value+"kmph");}}speed(); //line n3}}and this code fragment:Vehicle v = new Vehicle (100);v.increSpeed(60);What is the result?

A. Velocity with new speed 1 kmph
B. A compilation error occurs at line n1.
C. A compilation error occurs at line n2.
D. A compilation error occurs at line n3.