1Z0-805 Exam Questions
95 real 1Z0-805 exam questions with expert-verified answers and explanations. Page 1 of 2.
- Question #1Java Class Design
Given the following code fragment: public class Calc { public static void main (String [] args) { //* insert code here Line ** System.out.print("The decimal value is" + var); } } W...
binary literalsnumeric separatorsprimitive typesliteral syntax - Question #2Building Database Applications with JDBC
Given the code fragment: String query = "SELECT ID FROM Employee"; \\ Line 1 try (Statement stmt = conn.CreateStatement()) { \\ Line 2 ResultSet rs = stmt.executeQuery(query); \\ L...
StatementResultSetmultiple queriescursor behavior - Question #3Exceptions and Assertions
Given: public class SampleClass { public static void main(String[] args) { SampleClass sc = new SampleClass(); sc.processCD(); } Oracle 1Z0-805 Exam private void processCD() { try...
try-with-resourcesAutoCloseableexception propagationresource management - Question #4Localization
Given the code fragment: SimpleDateFormat sdf; Oracle 1Z0-805 Exam Which code fragment displays the three-character month abbreviation?
SimpleDateFormatmonth format patterndate formattingLocale - Question #5Java I/O Fundamentals
Given the code fragment: public static void processFile () throws IOException { Try (FileReader fr = new FileReader ("logfilesrc.txt"); FileWriter fw = new FileWriter ("logfilesdst...
try-with-resourcesresource closing orderFileReaderFileWriter - Question #6Building Database Applications with JDBC
Given this code fragment: ResultSet rs = null; try (Connection conn = DriverManager. getConnection (url) ) { Statement stmt = conn.createStatement(); rs stmt.executeQuery(query); /...
ResultSet scopetry-with-resourcesConnection lifecycleJDBC resources - Question #7Java I/O Fundamentals
View the Exhibit: Given the following code fragment: class Finder extends SimpleFileVisitor<Path> { private final PathMatcher matcher; private static int numMatches = 0; Finder() {...
SimpleFileVisitorPathMatcherglob patternNIO.2 file traversal - Question #8Java I/O Fundamentals
Given the following code fragment: public static void main(String[] args) { Path tempFile = null; try { Path p = Paths.get("emp"); tempFile = Files.createTempFile(p, "report", ".tm...
createTempFiletemp file lifecycleNIO.2BufferedWriter - Question #9Concurrency
Which two Capabilities does Java.util.concurcent.BlockingQueue provide to handle operation that cannot be handled immediately?
BlockingQueueblocking operationsproducer-consumerconcurrent collections - Question #10Java I/O Fundamentals
Which is true regarding the java.nio.file.Path Interface?
Path interfaceNIO.2WatchServicethread safety - Question #11Advanced Class Design
What are two benefits of a Factory design pattern?
Factory patterndesign patternsloose couplingconstructor encapsulation - Question #12Localization
Given the code fragment: SimpleDateFormat sdf = new SimpleDateFormat("zzzz", Locale.US); Oracle 1Z0-805 Exam System.out.println ("Result: " + sdf.format(today) ) ; What type of res...
SimpleDateFormattimezone format patterndate formattingLocale - Question #13Building Database Applications with JDBC
The advantage of a CallableStatement over a PreparedStatement is that it:
CallableStatementPreparedStatementstored proceduresJDBC statement types - Question #14Concurrency
Given: class Fibonacci extends RecursiveTask<Integer> { final int n; Fibonacci (int n) { this.n = n } Integer compute () { if (n <= 1) return n; Fibonacci f1 = new Fibonacci (n ?1)...
Fork/Join frameworkRecursiveTaskfork/join orderingparallel performance - Question #15Exceptions and Assertions
Given: public static void main(String[] args) throws Exception { try { processFile(); } catch(Exception e) { Throwable [] t = e.getSuppressed(); } } public static void processFile(...
suppressed exceptionsgetSuppressedtry-with-resourcesexception chaining - Question #16Java I/O Fundamentals
Given the code fragment: 11. public static getFileSize () throws IOException { 12. path file = paths.get ("ex.txt"); 13. //insert code here 14. System.out.println ("size: " + attr....
BasicFileAttributesPosixFileAttributesreadAttributesNIO.2 file attributes - Question #17Building Database Applications with JDBC
Which two statements are true about RowSet subinterfaces?
jdbcRowSetcachedRowSetFilteredRowSetRowSet interfaces - Question #18
Given the code fragment: public static void main(String[] args) { Path dir = Paths.get("d:\\company"); // insert code here. Line ** for (Path entry: stream) { System.out.println(en...
- Question #19Building Database Applications with JDBC
Consider the following five methods: Which method should you use to connect to a java Db database with JDBC 4.0, but not with previous versions of JDBC?
JDBC 4.0DriverManager.getConnectionautomatic driver loadingJDBC versions - Question #20
Given the code fragment: Locale loc1 = Locale.getDefault (); ResourceBundle messages = ResourceBundle.getBundle("MessageBundle", loc1); Which two statements are a valid way to re-a...
- Question #21Advanced Class Design
Given: public class TemperatureSensor { public TemperatureSensor () { } public double getCurrTemp () { // . . . method to retrieve temperature from a sensor Return temp; } } Which...
singleton patternprivate constructorstatic instancedesign patterns - Question #22Localization
Given the error message when running you application: Exception in thread "main" java.util.MissingResourceException: can't find bundle for base name messageBundle, Locale And given...
ResourceBundleMissingResourceExceptionCLASSPATHproperties file - Question #23Java I/O Fundamentals
Which two statements are true regarding the try with resources statement?
try-with-resourcesAutoCloseableCloseablecatch/finally ordering - Question #24Java Class Design
Given the code fragment: public class TestString { public static void main(String[] args) { String str=null; switch(str) { case "": System.out.println("blank"); break; case "null":...
switch on nullNullPointerExceptionString switchnull handling - Question #25Building Database Applications with JDBC
Given the code fragment: try { String query = "SELECT * FROM Employee WHERE ID=110"; Statement stmt = conn.createStatement(); ResultSet rs = stmt.executeQuery(query); // Line 13 Sy...
ResultSet cursornext() methodexecuteQueryJDBC result iteration - Question #26Java I/O Fundamentals
Given the code fragment: Path path1 = Paths.get("D:\\sales\\.\\quarterly\\..\\report"); path1 = path1.normalize(); Path path2 = path1.relativize(Paths.get("d:\\empdetails.dat")); p...
Path normalizationrelativizeresolveNIO.2 - Question #27Building Database Applications with JDBC
Given: Which design pattern moves the getPerson, createPerson, deletePerson, and updatePerson methods to a new class?
DAO patterndesign patternsCRUD operations - Question #28Concurrency
Given: ConcurrentMap<String, String> partList = new ConcurrentHashMap<> (); Which fragment puts a key/value pair in partList without the possibility of overwriting an existing Orac...
ConcurrentHashMapputIfAbsentatomic operationsthread safety - Question #29Building Database Applications with JDBC
Which three objects must a vendor provide implementations in its JDBC driver?
JDBC driverConnectionDriverManagerSQLException - Question #30Concurrency
Given: public class MyGrades { private final List<Integer> myGrades = new ArrayList<Integer>(); private final ReadWriteLock rwlock = new ReentrantReadWriteLock(); public void addGr...
ReentrantReadWriteLockread lockwrite lockconcurrency API - Question #31Java I/O Fundamentals
Which two methods are defined in the FileStore class print disk space information?
FileStoredisk spacegetTotalSpacegetUsableSpace - Question #32Java I/O Fundamentals
Given the code fragment: public static void main(String[] args) { Path file = Paths.get("D:\\company\\report.txt"); Oracle 1Z0-805 Exam try (SeekableByteChannel sbc = Files.newByte...
SeekableByteChannelOpenOptionNIO.2file channels - Question #33Java I/O Fundamentals
Which statement is true about the take method defined in the WatchService interface?
WatchServicetake methodwatch keyblocking - Question #34Exceptions and Assertions
Given the code fragment: private static void copyContents (File source, File target) { try {inputStream fis = new FileInputStream(source); outputStream fos = new FileOutputStream (...
multi-catchexception hierarchyIOExceptionFileNotFoundException - Question #35Java I/O Fundamentals
Which two statements are true about the walkFileTree method of the files class?
walkFileTreeFileVisitorsymbolic linksmaxDepth - Question #36Generics and Collections
Which code fragments print 1?
TreeSetiteratorSet deduplicationcollections - Question #37
Given the code fragment: public static void main(String[] args) { String source = "d:\\company\\info.txt"; String dest = "d:\\company\\emp\\info.txt"; //insert code fragment here L...
- Question #38Building Database Applications with JDBC
What design pattern does the Drivermanager.getconnection () method characterize?
Factory patternDriverManagerdesign patternsJDBC - Question #39Localization
Given the code fragment: dataFormat df; Oracle 1Z0-805 Exam Which statement defines a new DataFormat object that displays the default date format for the UK Locale?
DateFormatLocalegetDateInstancelocalization API - Question #40Localization
Given three resource bundles with these values set for menu1: ( The default resource bundle is written in US English.) English US resource Bundle Menu1 = small French resource Bund...
ResourceBundlelocale fallbackmissing bundledefault locale - Question #41Generics and Collections
Given: import java.util.*; public class StringApp { public static void main (String [] args) { Set <String> set = new TreeSet <> (); set.add("X"); set.add("Y"); set.add("X"); set.a...
TreeSetiteratorsorted orderSet uniqueness - Question #42Concurrency
Given the code fragment: List<Person> pList = new CopyOnWriteArrayList<Person>(); Which statement is true?
CopyOnWriteArrayListthread safetyconcurrent collectionsread semantics - Question #43Building Database Applications with JDBC
Given the fragment: public class CustomerApplication { Oracle 1Z0-805 Exam public static void main (String [] args) { CustomerDAO custDao = new CustomerDAOMemoryImp1 (); // . . . o...
DAO patternFactory patterndecouplinggetInstance - Question #44Localization
Given a resource bundle MessageBundle, what is the name of the default bundle file?
ResourceBundleproperties filedefault bundlenaming convention - Question #45Java I/O Fundamentals
Given the code fragment: public class Test { public static void main (String [] args) { Path path1 = Paths.get("D:\\sys\\asm\\.\\data\\..\\..\\mfg\\production.log"); System.out.pri...
Path normalizegetNameCountpath traversalNIO.2 - Question #46Building Database Applications with JDBC
You are using a database from XY/Data. What is a prerequisite for connecting to the database using a JDBC 4.0 driver from XY/Data?
JDBC 4.0driver classpathDriverManagerdriver loading - Question #47
Oracle 1Z0-805 Exam Two companies with similar robots have merged. You are asked to construct a new program that allows the features of the robots to be mixed and matched using com...
- Question #48Concurrency
Which three must be used when using the Java.util.concurrent package to execute a task that returns a result without blocking?
ExecutorServiceCallableFutureconcurrent package - Question #49Concurrency
Which statement creates a low-overhead, low contention random number generator that is isolated to a thread to generate a random number between 1 and 100?
ThreadLocalRandomrandom number generationthread isolationconcurrency utilities - Question #50Advanced Class Design
Given: public class DataCache { private static final DataCache instance = new DataCache (); public static DataCache getInstance () { return instance; } } Which design pattern best...
Singleton patternstatic initializationdesign patternsclass design