Skip to content

Java: Tools and Libraries for Everyone :Java Programming: Principles of Software Design (Java Programming and Software Engineering Fundamentals Specialization) Anawers 2025

1. Method that starts a Java program

✔️ main
❌ firstMethod
❌ _start
❌ begin


2. Argument type for the starting method

✔️ an array of Strings
❌ ArrayList<String>
❌ no arguments
❌ int and a String


3. Effect of declaring a field static

✔️ There is only one copy of that field for the entire class.
❌ Only changed inside class
❌ Only increases
❌ Cannot be changed once set


4. How “throw” is used

✔️ To make an exception occur intentionally when an error is detected.
❌ Handle exception
❌ Open file
❌ Transfer data


5. Best structure to create a Socket and handle IOException

✔️

try {
Socket s = new Socket(addr, port);
//code that uses s
}
catch(IOException ioe) {
//code to handle the exception
}

❌ try-use after catch
❌ create outside try
❌ use after try-catch (s may not exist)


6. Purpose of “finally”

✔️ Runs code whether or not an exception occurs.
❌ Run after loop
❌ When program exits
❌ Done debugging


7. What to pass into Files.newBufferedReader

✔️ a Path
❌ IOException
❌ Comparator
❌ FileResource


8. Package for reading from websites

✔️ java.net
❌ java.internet
❌ java.urls
❌ java.lolcats


9. Two programming principles shown by BufferedReader flexibility

✔️ Abstraction
✔️ Open/Closed Principle

❌ Everything Is A Number
❌ Astrachan’s Law
❌ Write Robust Code


📌 Summary Table

Q# Final Answer
1 main
2 array of Strings
3 Only one copy per class
4 Used to cause an exception
5 First try/catch option
6 Runs regardless of exception
7 Path
8 java.net
9 Abstraction + Open/Closed Principle