public class Car {
String name;
int price;
Engine eng; //---> Cant understand this logic
public int inceasePrice(int increment){
price = price + increment;
return price;
}
public Engine getEngine(){
return eng;
}
}
*************************************************
public class TestCar {
public static void main(String arg[]){
Car c1 = new Car();
c1.name="BMW";
c1.price=99999999;
c1.inceasePrice(100);
System.out.println(c1.price);
Engine e = new Engine();
e.mdNumber="AE9282";
e.milage=20;
c1.eng=e; //---> Cant understand this logic
System.out.println(c1.eng.mdNumber); //---> Cant understand this logic
System.out.println(c1.eng.milage); //---> Cant understand this logic
Instructor
Ashish Thakur Replied on 07/04/2020
Car has a price so we have "int price" in it
Car an Engine so we have "engine e" in it. Engine is a separate class
Just reference of that class is kept here
Thanks team. I got it