1Z0-804 Premium Bundle

1Z0-804 Premium Bundle

Java SE 7 Programmer II Exam Certification Exam

4.5 
(24555 ratings)
0 QuestionsPractice Tests
0 PDFPrint version
May 20, 2024Last update

Oracle 1Z0-804 Free Practice Questions

Q1. Given the Greetings.properties file, containing: 

What is the result? 

A. Compilation fails 

B. HELLO_MSG 

C. GOODGYE_NSG 

D. Hello, everyone! 

E. Goodbye everyone! 

Answer:

Explanation: 

The code will not compile. 

The problem is the following line: 

System.out.println(resource.getObject(1)); 

In particular getObject(1) throws the following error: 

Exception in thread "main" java.lang.RuntimeException: Uncompilable source code -Erroneous sym type: 

<any>.loadResourceBundle 

Note:getObject(String key) !!! String keyGets an object for the given key from this resource 

bundle or one of its parents. 

Q2. For which three objects must a vendor provide implementations in its JDBC driver? 

A. Time 

B. Date 

C. Statement 

D. ResultSet 

E. Connection 

F. SQLException 

G. DriverManager 

Answer: C,D,E 

Explanation: 

All JDBC drivers implement the four important JDBC classes: Driver, Connection, Statement, and ResultSet. 

Q3. Given the code format: 

SimpleDateFormat sdf; 

Which code statements will display the full text month name? 

A. sdf = new SimpleDateFormat ("mm", Locale.UK); System.out.println("Result:", sdf.format(new date())); 

B. sdf = new SimpleDateFormat ("MM", Locale.UK); System.out.println("Result:", sdf.format(new date())); 

C. sdf = new SimpleDateFormat ("MMM", Locale.UK); System.out.println("Result:", sdf.format(new date())); 

D. sdf = new SimpleDateFormat ("MMMM", Locale.UK); System.out.println("Result:", sdf.format(new date())); 

Answer:

Explanation: 

Typical output would be Current Month in M format: 2 Current Month in MM format: 02 Current Month in MMM format: Feb Current Month in MMMM format: February 

Q4. Given this code fragment: 

Assume that the SQL query returns records. 

What is the result? 

A. Compilation fails due to error at line 17 

B. The program prints Error 

C. The program prints each record 

D. Compilation fails at line 14 

Answer:

Q5. What are two differences between Callable and Runnable? 

A. A Callable can return a value when executing, but a Runnable cannot. 

B. A Callable can be executed by a ExecutorService, but a Runnable cannot. 

C. A Callable can be passed to a Thread, but a Runnable cannot. 

D. A Callable can throw an Exception when executing, but a Runnable cannot. 

Answer: A,D 

Explanation: 

The Callable interface is similar to Runnable, in that both are designed for classes whose instances arepotentially executed by another thread. A Runnable, however, does not return a result and cannot throw achecked exception. 

Q6. Given: 

What is the most likely result? 

A. Main One Two 

B. Main Two One 

C. One Two Main 

D. One Main Two 

E. Two Main One 

Answer:

Q7. Given: 

What is the result of invoking Car's scop method? 

A. Both vehicles and Motorized's stop methods are invoked. 

B. Vehicles stop method is invoked. 

C. Motorized's stop method is invoked-

D. The implementation of the Car's stop determines the behavior. 

E. Compilation fails. 

Answer:

Explanation: 

The Car class is implementing the methods. Methods are not implemented in interfaces. 

Q8. Given the following files in doc directory: -Index.htm 

-Service.html 

-Logo.gif 

-Title.jpg 

And the code fragment: 

What is the result, if doc is present in the current directory? 

A. No output is produced. 

B. index.htm 

C. index.htm userguide.txt logo.gif 

D. index.htm service.html userguide.txt logo.gif 

Answer:

Explanation: 

The Glob search expression is defined through "glob:*.htm, html, xml" The correct answer is A The glob is trying to match all the string. The correct way is 

glob:*.{htm,html,xml} 

and then would be found: 

Index.htm 

Service.html 

Q9. What will the following class print when run? 

A. javajava 

B. lavajava 

C. javajavac 

D. lavajavac 

E. None of these. 

Answer:

Q10. Given: 

What is the result? 

A. John-.-George-.-Paul-.-Ringo 

B. John George Paul Ringo 

C. John -George -Paul -Ringo -

D. An exception is thrown at runtime 

E. Compilation fails 

Answer:

Explanation: 

The split() method is used to split a string into an array of substrings, and returns the new array. regex: - followed by two characters 

Q11. Which two codes correctly represent a standard language locale code? 

A. ES 

B. FR 

C. U8 

D. Es 

E. fr 

F. u8 

Answer: A,B 

Explanation: 

Language codes are defined by ISO 639, an international standard that assigns two- and three-letter codes tomost languages of the world. Locale uses the two-letter codes to identify the target language. 

Q12. Given: Which statement is true? 

A. SportsCar must implement methods from TurboVehicle and steerable 

B. SportsCar must override methods defined by car. 

C. SportsCar must implement methods define by convertible. 

D. Instances of car can invoke convertible methods. 

Answer:

Explanation: 

To declare a class that implements an interface, you include an implements clause in the classdeclaration. By convention, the implements clause follows the extends clause, if there is one. Here are the some point that must be considered while implementing an interface (or interfaces) into a javaclass. A class implementing an interface must either implement all the methods of that interface otherwise known asthe abstract class. A class in java may extend at most one superclass because java does not allow multiple inheritance, by it mayimplement more than one interface. Multiple inheritance in java is achieved through the interfaces. When aclass implements more than one interface then implement statement requires a comma- separated list ofinterfaces to be implement by that class. 

Q13. Given: 

What is the result? 

A. Daniel 

B. Unknown 

C. It may print"unknown"or"Daniel"depending on the JVM implementation. 

D. Compilation fails. 

E. An exception is thrown at runtime. 

Answer:

Explanation: 

The compilation fails at line start(); Erstellen eines statischen Verweises auf die nicht statische Methode start() vom Typ Runner nicht m.glich.Exception in thread "main" java.lang.RuntimeException: Uncompilable source code - non-static method start()cannot be referenced from a static context 

Q14. Given: 

Which two classes correctly override the getDepth method? 

A. public class deep extends Deeper { 

protected Integer getDepth(){ 

return 5; 

}} 

B. public class deep extends Deeper { 

public Double getDepth() { 

return 5d; 

}} 

C. public class deep extends Deeper { 

public String getDepth () { 

}} 

D. public class deep extends Deeper { 

public Long getDepth (int d) { 

return 5L; 

}} 

E. public class deep extends Deeper { 

public Short getDepth () { 

return 5; 

}} 

Answer: A,E 

Explanation: 

Note: The abstract class Number is the superclass of classes Byte, Double, Float, Integer, Long, and Short. 

Subclasses of Number must provide methods to convert the represented numeric value to byte, double, float, int, long, and short. 

When class C extends B, we say that C is a "subclass" of B, and B is the "superclass" of C. This is called inheritence, because C inherited from B. 

Q15. Given: 

import java.util.concurrent.atomic.AtomicInteger; 

public class AtomicCounter { 

private AtomicInteger c = new AtomicInteger(0); 

public void increment() { 

// insert code here 

Which line of code, inserted inside the increment () method, will increment the value of c? 

A. c.addAndGet(); 

B. c++; 

C. c = c+1; 

D. c.getAndIncrement (); 

Answer:

Explanation: getAndIncrement 

public final int getAndIncrement() 

Atomically increment by one the current value. 

Reference:java.util.concurrent.atomic 

START 1Z0-804 EXAM