Suppose you have to instantiate a scanner object, what is the syntax for the try-with-resource block?
try(Scanner consoleScanner = new Scanner(System.in)) {
..
}Can you provide try-with resources statements without any explicit catch or finally blocks?
Yes
What is the requirements for a resource to be used with a try-with-resource statement?
That resource must implement java.lang.AutoCloseable interface
If an assertion is false, what does it throw?
AssertionError, derived from Error
How do you enable assertions for class/packages
?
To specify a class, use the class name. To specify the package name, use the package name followed by three dots …
java -ea:{Class} myPackage.MyProgram
java -ea:{package}… myPackage.MyProgram