Core Java interview questions
BigDecimal and Money, Code Reading and Debugging, Code Reading and Refactoring to Objects, Code Reading and State Safety, Code Reading with Collections, Code Reading with Exceptions
473 questions with answers and explanations · 472 flashcards
Questions (page 10 of 10)
- Which of the following statements correctly initializes a BigDecimal with a string value for a product price?Multiple choiceHard
- Why is it important to catch specific exceptions rather than general ones?Multiple choiceMedium
- Why might using a primitive type be preferable in performance-critical Java code?Multiple choiceEasy
- What does the following code snippet, assuming 'Integer.valueOf' is used evaluate to?Multiple choiceMedium
- Which statement is true regarding exception propagation?Multiple choiceEasy
- Why does an interface in Java matter in this design?Multiple choiceEasy
- Which keyword is used in Java to declare a constant for the maximum quantity of products?Multiple choiceEasy
- In a method calculating the shipping cost, where should you declare a variable to ensure it is not accessible outside the method?Multiple choiceEasy
- Consider the code snippet below. What will be the output when the divide method is called with a divisor of 0?Multiple choiceMedium
- What happens if you attempt to call a method that is not defined in the superclass using a superclass reference pointing to a subclass object?Multiple choiceMedium
- Which of the following statements is true regarding wrapper classes in Java?Multiple choiceEasy
- In the context of an e-commerce checkout method, what issue might arise from shadowing a method parameter with a local variable of the same name?Multiple choiceHard
- What will be the output of the following code involving polymorphism?Multiple choiceHard
- What does it mean when a method signature includes 'throws IOException'?Multiple choiceEasy
- Given the following code, which method will be executed at runtime? class Product { void display() { System.out.println("Product"); } } class Book extends…Multiple choiceMedium
- Why does the 'throw' keyword matter in practice?Multiple choiceMedium
- Which of the following data types is best for storing a product's stock quantity?Multiple choiceEasy
- Why does the following code not compile?Multiple choiceHard
- Which data type to store a product's SKU (Stock Keeping Unit) in Java is the best fit?Multiple choiceMedium
- If you incorrectly declare a product's price as 'double price = 19.99;', what kind of problem might you encounter in calculations?Multiple choiceHard
- If a method signature changes from using primitive int to Integer, what potential issue might arise?Multiple choiceHard
- In a Java application, how can you ensure that critical resources are released even if an exception occurs?Multiple choiceHard
- Which type is the cleanest fit for product quantity in a beginner checkout flow?Multiple choiceEasy