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

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899559
Joined: Mon Aug 02, 2021 8:13 am

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

Post 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.
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!

This question has been solved and has 1 reply.

You must be registered to view answers and replies in this topic. Registration is free.


Register Login
 
Post Reply