Count the beans

Report a typo

How many beans of InkSupply would be created in the code below?

Java
@Component
public class InkSupply {
    // a constructor
}
@Component
public class Scanner {

    @Autowired
    private InkSupply inkSupply;

    @Autowired
    public Scanner(InkSupply inkSupply) {
        this.inkSupply = inkSupply;
    }
}
@Component
public class Printer {

    @Autowired
    private InkSupply inkSupply;
}
Kotlin
@Component
class InkSupply {
    // a constructor
}
@Component
class Scanner {
    @Autowired
    private val inkSupply: InkSupply

    @Autowired
    constructor(inkSupply: InkSupply) {
        this.inkSupply = inkSupply
    }

}
@Component
class Printer {
    @Autowired
    private lateinit var inkSupply: InkSupply
}

Enter a number as your answer.

Enter a number
___

Create a free account to access the full topic