1Z0-829 Flashcards
What is the command line used to compile the Java class Wolf.java in the default package, and what file does it generate?
- javac Wolf.java
-
Wolf.class
Run: javac Wolf.java (and it generates Wolf.class)
True or false?
An interface can extend multiple interfaces.
True
What security attack does using a PrepraredStatement help with?
SQL injection
True or false?
A static method is allowed to reference an instance variable.
False
(except through a reference to a class instance)
What methods on PreparedStatement can run a DELETE SQL statement?
executeUpdate() and execute()
What command is used to create a runtime image?
jlink
True or false?
The sorted() intermediate operation has overloaded versions that allow passing or omitting a Comparator.
True
Which Collections method provides a thread-safe version of an existing Map?
Collections.synchronizedMap()
True or false?
A private static interface method can access a default interface method within the same interface.
False
Given p || q, where both p and q are true expressions, which side will not be evaluated at runtime?
q
What method is used to retrieve a parallel stream from an existing stream?
parallel()
What is unreachable code?
Any lines of code that the compiler determines it is not possible to reach at runtime
True or false? Arrays.asList() returns an immutable list.
False. It returns a fixed-sized list backed by an array.
True or false? Polymorphism allows an object to be passed as a class it inherits but not an interface type.
False. Polymorphism allows an object to be passed by any reference type that the class inherits.
What is a redundant package import?
A package import that is unnecessary. Removing the import does not prevent the code from compiling.
What NIO.2 Files methods allow you to both read and write file attributes?
Files.getFileAttributeView()
What is a locale category, and how is it used?
A locale category is a way to differentiate between the display and formatting of locale-based values.
Which method should be called before calling mark() on an arbitrary InputStream?
markSupported()
True or false? Objects in Java can inherit at most one class.
False. While Java does rely on single inheritance, a class can extend another class, so a single class may inherit multiple classes.
What does executeQuery() return in JDBC?
ResultSet
True or false? If a module doesn’t contain a module-info file, one is automatically generated.
False
Under what conditions may a resource created before a try-with-resources statement be used in a try-with-resources declaration?
The resource must be marked final or effectively final.
True or false? If a method has an int return type and does not throw an exception, it must return a value.
True
Name two ways to prevent an immutable class from being extended by a mutable subclass.
Mark the class final or make all of the constructors private.