Oracle 1Z0-804 Online Practice
Questions and Exam Preparation
1Z0-804 Exam Details
Exam Code
:1Z0-804
Exam Name
:Java SE 7 Programmer II
Certification
:Oracle Certifications
Vendor
:Oracle
Total Questions
:150 Q&As
Last Updated
:Dec 08, 2021
Oracle 1Z0-804 Online Questions &
Answers
Question 91:
Give:
public class Test {
public static void main(String[] args) {
String svar= "sports cars";
svar.replace(svar,"convertibles");
System.out.printf("There are %3$s %2$s and %d trucks.",5,svar,2+7);
}
}
What is the result?
A. There are 27 sports cars and 5 trucks B. There are 27 convertibles and 5 trucks C. There are 9 sports cars and 5 trucks D. There are 9 convertibles and 5 trucks E. IllegalFormatConversionException is thrown at runtime
C. There are 9 sports cars and 5 trucks
Question 92:
Given the following code fragment:
public static void main(String[] args) {
Connection conn = null;
Deque myDeque = new ArrayDeque<>();
myDeque.add("one");
myDeque.add("two");
myDeque.add("three");
System.out.println(myDeque.remove());
}
What is the result?
A. Three B. One C. Compilation fails D. The program runs, but prints no outout
B. One
The ArrayDeque.remove() method retrieves and removes the head of the queue represented by this deque. The head of the queue is item "one". Reference: java.util Class ArrayDeque
Question 93:
Given:
interface Rideable {
public String ride() { return "riding "; }
}
class Horse implements Rideable {
public String ride() { return "cantering "; }
}
class Icelandic extends Horse implements Rideable {
A. riding riding tolting B. riding riding cantering C. tolting cantering tolting D. tolting cantering cantering E. Compilation fails. F. An exception is thrown at runtime.
E. Compilation fails.
The compilation fails at:
interface Rideable {
public String ride() { return "riding ";}
}
Error due to: interface methods cannot have body.
Question 94:
Given two classes in separate files:
package a.b;
/ / import statement
public class parent
child c = new child();
package a.b.c;
public class child{
}
Which two import statements can make the a.b.parent class compliable?
A. import a.b.c.Parent; B. import a.b.c.Child; C. import a.b.c.*; D. import a.b.*; E. import a.*;
B. import a.b.c.Child; C. import a.b.c.*;
B: To import a specific member into the current file, put an import statement at the beginning of the file before any type definitions but after the package statement, if there is one.
C: To import all the types contained in a particular package, use the import statement with the asterisk (*) wildcard character. Reference: The Java Tutorials, Using Package Members
Question 95:
Given:
public abstract class Account {
abstract void deposit (double amt);
public abstract Boolean withdraw (double amt);
}
public class CheckingAccount extends Account {
}
What two changes, made independently, will enable the code to compile?
A. Change the signature of Account to: public class Account. B. Change the signature of CheckingAccount to: public abstract CheckingAccount C. Implement private methods for deposit and withdraw in CheckingAccount. D. Implement public methods for deposit and withdraw in CheckingAccount. E. Change Signature of checkingAccount to: CheckingAccount implements Account. F. Make Account an interface.
B. Change the signature of CheckingAccount to: public abstract CheckingAccount F. Make Account an interface.
B: Unlike interfaces, abstract classes can contain fields that are not static and final, and they can contain implemented methods. Such abstract classes are similar to interfaces, except that they provide a partial implementation, leaving it to subclasses to complete the implementation.
F: If an abstract class contains only abstract method declarations, it should be declared as an interface instead.
Question 96:
Given:
public class Test {
void display(String[] arr) {
try {
System.out.print(arr[2]);
} catch(ArrayIndexOutOfBoundsException |
NullPointerException e) {
e = new Exception();
throw e;
}
}
public static void main(String[] args) throws Exception {
try {
String[] arr = {"Unix","Solaris",null};
new Test().display(arr);
} catch(Exception e) {
System.err.print(e.getClass());
}
}
}
What is the result?
A. Null B. class java.lang.ArraylndexOutOfBoundsException C. class java.lang.NullPointerException D. class java.lang.Exception E. Compilation fails.
E. Compilation fails.
error: incompatible types e = new Exception(); required: RuntimeException found: Exception
Question 97:
Given:
class Deeper {
public Number getDepth() {
return 10;
}
}
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 "5"; } } 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; } }
A. public class deep extends Deeper { protected integer getDepth(){ return 5; } } E. public class deep extends Deeper { public short getDepth () { return 5; } }
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.
Question 98:
Given:
From what threading problem does the program suffer?
A. deadlock B. livelock C. starvation D. race condition
B. livelock
A thread often acts in response to the action of another thread. If the other thread's action is also a response to the action of another thread, thenlivelock may result.
As with deadlock, livelocked threads are unable to make further progress. However, the threads are not blocked -- they are simply too busy responding to each other to resume work. This is comparable to two people attempting to pass each
other in a corridor:
Alphonse moves to his left to let Gaston pass, while Gaston moves to his right to let Alphonse pass. Seeing that they are still blocking each other, Alphone moves to his right, while Gaston moves to his left. They're still blocking each other,
so...
Question 99:
Given:
StringBuffer b = new StringBuffer("3");
System.out.print(5+4+b+2+1);
What is the result?
A. 54321 B. 9321 C. 5433 D. 933 E. Output is Similar to: 9java.lang.StringBuffer@100490121. F. Compilation fails.
F. Compilation fails.
The code will not compile.
The print function cannot handle the mixture of integers and strings.
Exception in thread "main" java.lang.RuntimeException: Uncompilable source code - Erroneous tree type
Question 100:
ITEM Table
*
ID, INTEGER: PK
*
DESCRIP, VARCHAR(100)
*
PRICE, REAL
*
QUALITY, INTEGER
And given the code fragment (assuming that the SQL query is valid):
Nowadays, the certification exams become more and more important and required by more and more
enterprises when applying for a job. But how to prepare for the exam effectively? How to prepare
for the exam in a short time with less efforts? How to get a ideal result and how to find the
most reliable resources? Here on Vcedump.com, you will find all the answers.
Vcedump.com provide not only Oracle exam questions,
answers and explanations but also complete assistance on your exam preparation and certification
application. If you are confused on your 1Z0-804 exam preparations
and Oracle certification application, do not hesitate to visit our
Vcedump.com to find your solutions here.