Читать книгу OCP Oracle Certified Professional Java SE 17 Developer Study Guide - Jeanne Boyarsky - Страница 125
Code Formatting on the Exam
ОглавлениеNot all questions will include package declarations and imports. Don't worry about missing package statements or imports unless you are asked about them. The following are common cases where you don't need to check the imports:
Code that begins with a class name
Code that begins with a method declaration
Code that begins with a code snippet that would normally be inside a class or method
Code that has line numbers that don't begin with 1
You'll see code that doesn't have a method. When this happens, assume any necessary plumbing code like the main()
method and class definition were written correctly. You're just being asked if the part of the code you're shown compiles when dropped into valid surrounding code. Finally, remember that extra whitespace doesn't matter in Java syntax. The exam may use varying amounts of whitespace to trick you.