OCPJP 7 Upgrade Free Mock Exam

Question 1 of 13 [Language Enhancements]
A developer wants to implement switch statement.
Which of the following type Java SE 7 switch can accept?
Choice 1String class
Choice 2Character
Choice 3Byte
Choice 4Short
Choice 5Integer
Choice 6All the above
Question 2 of 13 [Language Enhancements]
Code :

package com.epractizelabs.cart;
public class ProductNameFinder {
public static String getProductName(String productId) {
String productName = null;
if (productId == null) {
return "ERROR";
}

switch (productId) {
case "15898-30": productName = "SCEA 5 Part 1 Training Lab";
break;

case "15898-31": productName = "SCEA 5 Part 2 and Part 3 Training Lab";
break;

case "15898-62": productName = "OCP Java SE 7 Training Lab";
break;

default: productName = "ERROR";
break;
}

return productName;
}
public static void main(String[] args) {
String productId = "15898-62";
String productName = ProductNameFinder.getProductName(productId);
System.out.println(productName);
}
}
What is the output of the above code?
Choice 1Compilation error (string cannot be used in switch)
Choice 2Runtime error
Choice 3OCP Java SE 7 Training Lab
Question 3 of 13 [Language Enhancements]
Which method is used to get the list of all installed locales?
Choice 1Locale.getAllLocales();
Choice 2Locale.getAvailableLocales();
Choice 3Locale.getAllDefaultLocales();
Choice 4Locale.getDefaultLocales();
Choice 5Locale.getInstalledLocales();
Question 4 of 13 [Design Patterns]
You are assigned to develop a print spooler Java class. This class must be accessed by disparate objects throughout your application components.
Which pattern can you use for implementing print spooler class?
Choice 1Facade
Choice 2Singleton
Choice 3Factory
Question 5 of 13 [Design Patterns]
You are assigned to complete data access code for a small desktop application. The application currently uses flat text files to store data and planned to use XML for RDBMS in the near future.
Which design pattern can be used to serve data access object based on database type (text file/ XML / RDBMS)?
Choice 1Singleton
Choice 2Builder
Choice 3Factory
Question 6 of 13 [Database Applications with JDBC]
Which class can obtain a RowSetFactory?
Choice 1RowFactory
Choice 2RowSetProvider
Choice 3CachedRowSet
Question 7 of 13 [Database Applications with JDBC]
Which of the following code is valid?
Choice 1
RowSetFactory aFactory = RowSetProvider.newFactory();
CachedRowSet crs = aFactory.createCachedRowSet();
Choice 2
RowSetFactory aFactory = RowSetProvider.getFactory();
CachedRowSet crs = aFactory.createCachedRowSet();
Choice 3
RowSetFactory aFactory = RowSetProvider.newFactory();
CachedRowSet crs = aFactory.getCachedRowSet();
Question 8 of 13 [Database Applications with JDBC]
Which of the following can be used to execute precompiled SQL statement?
Choice 1PreparedStatement
Choice 2Statement
Choice 3PrepareStatement
Question 9 of 13 [Concurrency]
Which interface is used instead of explicitly creating threads?
Choice 1Executor
Choice 2Runnable
Choice 3Thread
Question 10 of 13 [Concurrency]
Select the Executor method.
Choice 1void run(Runnable command)
Choice 2void execute(Runnable command)
Choice 3void execute(Thread command)
Question 11 of 13 [Locaxlization]
Given the code fragment:Locale locale=null;
ResourceBundle eplResources=null;


You want to load property file named ERACTIZE_RES.properties.
Which of the following code can achieve this goal.
Choice 1eplResources=ResourceBundle.getBundle("ERACTIZE_RES",Locale.getDefault());
Choice 2eplResources=ResourceBundle.getBundle("ERACTIZE_RES. properties",Locale.getDefault());
Choice 3eplResources=ResourceBundle.getBundle("ERACTIZE_RES ");
Question 12 of 13 [Java File I/O]
Which class is a programmatic representation of a path in the file system?
Choice 1Files
Choice 2Path
Choice 3Folder
Question 13 of 13 [Java File I/O]
Which of the following method returns PathMatcher object?
Choice 1FileSystem.getPathMatcher(String syntaxAndPattern)
Choice 2File.getPathMatcher(String syntaxAndPattern)
Choice 3Path.getPathMatcher(String syntaxAndPattern)