Java
Programming and Technical
Programming
class ProductNotFoundException extends Exception {
//Some code
}
class Shop {
public void findProduct(int productId) throws ProductNotFoundException {
//some code
throw new ProductNotFoundException();
//some code
}
}
class ABCShop{
public void findProductsList(){
new Shop().findProduct(101);
}
}
Which of the following statement(s) are true for the above code?
A. This code will compile if we add throws ProductNotFoundException in the signature of method findProductsList().
B. This code will compile but returns no output
C. This code will compile if we add a try-catch block in findProductsList().
D. This code will compile if in method findProductsList () returns a list instead of void
Read Solution (Total 1)
-
- C. This code will complie if in method findProductList () returns a list instead of void
- 2 years agoHelpfull: Yes(0) No(0)
Java Other Question