Answer is A
No compilation fail
c1.type and c1.maxSpeed have default values assinged to them in the Vehicle class.
calling c1.type will fetch the Vehicle.typevalue of "4W"
calling c1.maxSpeed will fetch the Vehicle.maxSpeed value of 100
Answer is A.
To test:
package teste;
class Vehicle{
String type = "4W";
int maxSpeed = 100;
Vehicle(String type, int maxSpeed){ //Construtor da classe Pai
this.type=type;
this.maxSpeed=maxSpeed;
}
Vehicle(){} // Construtor Default
} // fim da classe Vehicle
public class Car extends Vehicle{
String trans;
Car(String trans){ //line n1
this.trans = trans;
}
Car(String type, int maxSpeed, String trans){
super(type, maxSpeed); //line n2
this.trans = trans;
}
public static void main(String[] args) {
Car c1=new Car("Auto");
Car c2=new Car("4W", 150, "Manual");
System.out.println(c1.type + " " +c1.maxSpeed + " " + c1.trans);
System.out.println(c2.type + " " +c2.maxSpeed + " " + c2.trans);
} // Fim da main
} // Fim da class Car
Answer: A
Tested: Yes
Notes: No issue of compilation in this case. Both c1 and c2 are calling super constructors (c1 is using an implicit call), which are defined properly.
A voting comment increases the vote count for the chosen answer by one.
Upvoting a comment with a selected answer will also increase the vote count towards that answer by one.
So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.
vic88
1 week, 6 days ago9de58b9
7 months agoandradaradu
1 year, 1 month agoarjunrawatirissoftware
1 year, 2 months agoa_really_reliable_programmer
1 year, 3 months agoa_really_reliable_programmer
1 year, 3 months agombns
1 year, 4 months agoswgreen
3 months, 3 weeks agosamarrrr
1 year, 7 months agomrstevebang
1 year, 7 months agoVicky_65
1 year, 8 months agomiankita
1 year, 11 months agowillokans
2 years agocarloswork
2 years, 1 month agoDef8
2 years, 1 month agoRoxyFoxy
2 years, 2 months agokkaayyyy
2 years, 3 months agoAncient1
2 years, 3 months agoPhilip0908
2 years, 3 months ago