aiotestking uk

1Z0-804 Exam Questions - Online Test


1Z0-804 Premium VCE File

Learn More 100% Pass Guarantee - Dumps Verified - Instant Download
150 Lectures, 20 Hours

Q1. 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 

Q2. Given that myfile.txt contains: 

What is the result? 

A. new file.txt contains: 

1: First 

2: Second 

3:

 Third 

B. 

new file.txt contains: 

1:

 First 2: Second 3: Third 

C. 

newfile.txt is empty 

D. 

an exception is thrown at runtime 

E. 

compilation fails 

Answer:

Explanation: 

For each line in the file myfile.text the line number and the line is written into newfile.txt. 

Q3. Given: Which two statements concerning the OO concepts "IS-A" and "HAS-A" are true? 

A. Flimmer is-a Glommer. 

B. Flommer has-a String. 

C. Tagget has-a Glommer. 

D. Flimmer is-a ArrayList. 

E. Tagget has-a doStuff() 

F. Tagget is-a Glommer. 

Answer: B,F 

Explanation: 

B: The relationship modeled by composition is often referred to as the "has-a" relationship. 

Here Flommer hasaString. 

E: The has-a relationship has an encapsulation feature (like private or protected modifier 

used before eachmember field or method). 

Here Tagget has-a method doStuff() 

F: Tagget implements Glommer. 

Tagget is-a Glommer. 

Note: The has-a relationship has an encapsulation feature (like private or protected 

modifier used before eachmember field or method). 

Q4. Given the class? 

What is the result? 

A. Jane Doe John Doe Joe Shmoe 

B. John Doe Jane Doe Joe Shmoe 

C. Joe Shmoe John Doe Jane Doe 

D. Joe Shmoe Jane Doe John Doe 

E. Jane Doe Joe Shmoe John Doe 

F. John Doe Joe Shmoe Jane Doe 

Answer:

Explanation: The list will be sorted alphabetically (Lastname / Firstname). first sorted by Lastname if Lastname equals, sorted by firstname Output will be: Jane Doe John Doe Joe Shmoe 

Q5. 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 

Q6. You have been asked to create a ResourceBundle file to localize an application. 

Which code example specifies valid keys menu1 and menu2 with values of File Menu and View Menu? 

A. <key name ="menu1">File Menu</key> <key name ="menu1">View Menu</key> 

B. <key> menu1</key><File Menu>File Menu </value> <key> menu1</key><File Menu>View Menu </value> 

C. menu1m File menu, menu2, view menu 

D. menu1 = File Menu menu2 = View Menu 

Answer:

Explanation: 

A properties file is a simple text file. You can create and maintain a properties file with just aboutany text editor. 

You should always create a default properties file. The name of this file begins with the base name of your ResourceBundle and ends with the .properties suffix. In the PropertiesDemo program the base name is LabelsBundle. Therefore the default properties file is called LabelsBundle.properties. The following examplefilecontains the following lines: # This is the default LabelsBundle.properties file s1 = computer s2 = disk s3 = monitor s4 = keyboard Note that in the preceding file the comment lines begin with a pound sign (#). The other lines contain key-valuepairs. The key is on the left side of the equal sign and the value is on the right. For instance, s2 is the key thatcorresponds to the value disk. The key is arbitrary. We could have called s2 something else, like msg5 ordiskID. Once defined, however, the key should not change because it is referenced in the source code. Thevalues may be changed. In fact, when your localizers create new properties files to accommodate additionallanguages, they will translate the values into various languages. 

Q7. Given the code fragment: 

DateFormat df; 

Which statement defines a new Dateformat object that displays the default date format for the UK Locale? 

A. df = DateFormat.getDateInstance (DateFormat.DEFAULT, Locale (UK)); 

B. df = DateFormat.getDateInstance (DateFormat.DEFAULT, UK); 

C. df = DateFormat.getDateInstance (DateFormat.DEFAULT, Locale.UK); 

D. df = new DateFormat.getDateInstance (DateFormat.DEFAULT, Locale.UK); 

E. df = new DateFormat.getDateInstance (DateFormat.DEFAULT, Locale (UK)); 

Answer:

Explanation: 

The UK locale is constructed withLocale.UK. 

To format a date for a different Locale, specify it in the call to getDateInstance(). 

DateFormat df = 

DateFormat.getDateInstance(DateFormat.LONG, Locale.FRANCE); 

Note: getDateInstance( int style, Locale aLocale ) 

Gets the date formatter with the given formatting style for the given locale. 

Reference:Class DateFormat 

Q8. Given: 

What is the result? 

A. false \sales\quarter\ . . \qtrlreport.txt 

B. false \quarter\ . . \qtrlreport.txt 

C. true . . \ . . \ . . \ annualreport.txt 

D. true \ . . \ . . \annualreport.txt 

Answer:

Explanation: 

( richtig !! import java.nio.file.Path; import java.nio.file.Paths; ) original-Aufgabe war ( falsch >> import java.io.file.Path; import java.io.file.Paths; ) The relativize method that can be used to construct a relative path between two paths. relativize Path relativize(Path other) Constructs a relative path between this path and a given path. Parameters:other - the path to relativize against this path Returns:the resulting relative path, or an empty path if both paths are equal Note: Relativization is the inverse of resolution. This method attempts to construct a relative path that when resolvedagainst this path, yields a path that locates the same file as the given path. For18example, on UNIX, if this path is "/a/b" and the given path is "/a/b/c/d" then the resulting relative path would be"c/d". Where this path and the given path do not have a root component, then a relative path can beconstructed. A relative path cannot be constructed if only one of the paths have a root component. Where bothpaths have a root component then it is implementation dependent if a relative path can be constructed. If thispath and the given path are equal then an empty path is returned. For any two normalized paths p and q, where q does not have a root component,p.relativize(p.resolve(q)).equals(q) When symbolic links are supported, then whether the resulting path, when resolved against this path, yields apath that can be used to locate the same file as other is implementation dependent. For example, if this path is"/a/b" and the given path is "/a/x" then the resulting relative path may be "../x". If "b" is a symbolic link then isimplementation dependent if "a/b/../x" would locate the same file as "/a/x". 

Q9. Which three statements are correct about thread's sleep method? 

A. The sleep (long) method parameter defines a delay in milliseconds. 

B. The sloop (long) method parameter defines a delay in microseconds. 

C. A thread is guaranteed to continue execution after the exact amount of time defined in the sleep (long)parameter. 

D. A thread can continue execution before the amount of time defined in the sleep (long) parameter. 

E. A thread can continue execution after the amount of time defined in the sleep (long) parameter 

F. Only runtime exceptions are thrown by the sleep method. 

G. A thread loses all object monitors (lock flags) when calling the sleep method. 

Answer: A,C,E 

Explanation: 

sleep (long millis) not B Causes the currently executing thread to sleep (temporarily cease execution) for the specified number ofmilliseconds(A, not B) millis - the length of time to sleep in milliseconds. throws InterruptedException: - if another thread has interrupted the current thread. The interrupted status ofthe current thread is cleared when this exception is thrown. java.lang.Throwable java.lang.Exception java.lang.InterruptedException The thread does not lose ownership of any monitors. It means that if the thread has an object-monitor, all otherthreads that need that monitor are blocked. This method can be called regardless whether the thread has any monitor or not. 

Q10. Given the code fragment: What is the result when infected() is invoked? 

A. before try catch finally after 

B. before catch finally after 

C. before catch after 

D. before catch finally 

E. before catch 

Answer:

Explanation: 

The following line throws and exception: 

int i = 1/0; 

This exception is caught by: 

catch(Exception e) { 

System.out.print("catch "); 

throw e; 

Lastly, the finally statement is run as the finally block always executes when the try block 

exits. This ensuresthat the finally block is executed even if an unexpected exception 

occurs. 

Reference: Java Tutorial,The finally Block