A. p001 Widget p002 X-Large Widget B. p002 Large Widget p001 Widget C. p002 X-large Widget p001 Widget D. p001 Widget p002 Large Widget E. compilation fails
public class Manager extends Employee implements Serializable {
String mgrId;
public static void main(String s[]) throws Exception {
Manager mgr = new Manager();
What is the result?
A. M001, , B. M001, null, null C. M001, Sam, D. M001, Sam, null E. M001, Sam, ABC Inc F. Compilation fails G. A NullPointerException is thrown at runtime
E. M001, Sam, ABC Inc
Question 84:
Given the code fragment:
public class DisplaValues {
public void printNums (int [] nums){
for (int number: nums) { System.err.println(number);
}
}
}
Assume the method printNums is passed a valid array containing data. Why is this method not producing output on the console?
A. There is a compilation error. B. There is a runtime exception. C. The variable number is not initialized. D. Standard error is mapped to another destination.
D. Standard error is mapped to another destination.
The code compiles fine.
The code runs fine.
The err stream can be redirected.
Note:
System.out.println -> Sends the output to a standard output stream. Generally monitor.
System.err.println -> Sends the output to a standard error stream. Generally monitor.
err is the "standard" error output stream. This stream is already open and ready to accept output data.
Typically this stream corresponds to display output or another output destination specified by the host environment or user. By convention, this output stream is used to display error
messages or other information that should come to the immediate attention of a user even if the principal output stream, the value of the variable out, has been redirected to a file or other destination that is typically not continuously monitored.
Reference: java.lang.System
Question 85:
Given:
1.
interface Writable {
2.
void write (String s);
3.
}
4 .
5.
abstract class Writer implements Writable {
6.
// Line ***
7.
}
Which two statements are true about the writer class?
A. It compiles without any changes. B. It compiles if the code void write (String s); is added at line ***. C. It compiles if the code void write (); is added at line ***. D. It compiles if the code void write (string s) { } is added at line ***. E. It compiles if the code write () {} is added at line ***.
A. It compiles without any changes. E. It compiles if the code write () {} is added at line ***.
An abstract class does not need to implement the interface methods.
Question 86:
The two methods of code reuse that aggregate the features located in multiple classes are ____________ .
A. Inheritance B. Copy and Paste C. Composition D. Refactoring E. Virtual Method Invocation
A. Inheritance C. Composition
A: Inheritance is a way of reusing code and building bigger more functional objects from a basic object.
The original little object, the parent, is called the super-class. The more functional object that inherits from it is called the sub-class .
C: When your goal is code reuse, composition provides an approach that yields easier-to-change code.
Question 87:
Given:
class InvalidAgeException extends IllegalArgumentException { }
What is the result of compiling and executing this code fragment?
A. The program prints employee IDs B. The program prints customer IDs C. The program prints Error D. Compilation fails on line ***
A. The program prints employee IDs
The program compiles and runs fine. Both executeQuery statements will run.
The first executeQuery statement (ResultSet rs = stmt.executeQuery(query);) will set the rs Resultset. It will be used in the while loop. EmployIDs will be printed.
Note: Executes the given SQL statement, which returns a single ResultSet object.
Parameters:
sql - an SQL statement to be sent to the database, typically a static SQL SELECT statement
Returns:
a ResultSet object that contains the data produced by the given query; never null
Question 89:
A valid reason to declare a class as abstract is to:
A. define methods within a parent class, which may not be overridden in a child class B. define common method signatures in a class, while forcing child classes to contain unique method implementations C. prevent instance variables from being accessed D. prevent a class from being extended E. define a class that prevents variable state from being stored when object Instances are serialized F. define a class with methods that cannot be concurrently called by multiple threads
B. define common method signatures in a class, while forcing child classes to contain unique method implementations
Note: An abstract method in Java is something like a pure virtual function in C++ (i.e., a virtual function that is declared = 0). In C++, a class that contains a pure virtual function is called an abstract class and cannot be instantiated. The same
is true of Java classes that contain abstract methods.
Any class with an abstract method is automatically abstract itself and must be declared as such.
An abstract class cannot be instantiated.
A subclass of an abstract class can be instantiated only if it overrides each of the abstract methods of its superclass and provides an implementation (i.e., a method body) for all of them. Such a class is often called a concrete subclass, to
emphasize the fact that it is not abstract.
If a subclass of an abstract class does not implement all the abstract methods it inherits, that subclass is itself abstract.
static, private, and final methods cannot be abstract, since these types of methods cannot be overridden by a subclass. Similarly, a final class cannot contain any abstract methods.
A class can be declared abstract even if it does not actually have any abstract methods.
Declaring such a class abstract indicates that the implementation is somehow incomplete and is meant to serve as a superclass for one or more subclasses that will complete the implementation. Such a class cannot be instantiated.
Question 90:
Given:
interface Event {
String type = "Event";
public void details();
}
class Quiz {
static String type = "Quiz";
}
public classPracticeQuiz extends Quiz implements Event {
public void details() {
System.out.print(type);
}
public static void main(String[] args) {
new PracticeQuiz().details();
System.out.print(" " + type);
}
}
What is the result?
A. Event Quiz B. Event Event C. Quiz Quiz D. Quiz Event E. Compilation fails
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.