Which code fragment creates an instance of Car?

Given:
interface Rideable {Car getCar (String name); }
class Car {
private String name;
public Car (String name) {
this.name = name;
}
}
Which code fragment creates an instance of Car?

Given:
interface Rideable {Car getCar (String name); }
class Car {
private String name;
public Car (String name) {
this.name = name;
}
}
Which code fragment creates an instance of Car?

A.
Car auto = Car (“MyCar”): : new;

B.
Car auto = Car : : new;
Car vehicle = auto : : getCar(“MyCar”);

C.
Rideable rider = Car : : new;
Car vehicle = rider.getCar(“MyCar”);

D.
Car vehicle = Rideable : : new : : getCar(“MyCar”);



Leave a Reply 2

Your email address will not be published. Required fields are marked *