Oracle 1z0-808
Oracle 1z0-808
Java SE 8 Programmer I
Version: 8.0
Oracle 1z0-808 Exam
QUESTION NO: 1
Given:
A.
200.0 : 100.0
B.
400.0 : 200.0
C.
400.0 : 100.0
D.
Compilation fails.
Answer: C
Explanation:
QUESTION NO: 2
A.
10 Hello World!
B.
Hello Universe!
C.
Hello World!
D.
Compilation fails.
Answer: A
Explanation:
QUESTION NO: 3
A.
May 04, 2014T00:00:00.000
B.
2014-05-04T00:00: 00. 000
C.
5/4/14T00:00:00.000
D.
Answer: D
Explanation:
QUESTION NO: 4
A.
Sum is 600
B.
Compilation fails at line n1.
C.
Compilation fails at line n2.
D.
A ClassCastException is thrown at line n1.
E.
A ClassCastException is thrown at line n2.
Answer: C
Explanation:
QUESTION NO: 5
What is the name of the Java concept that uses access modifiers to protect variables and hide
them within a class?
"Pass Any Exam. Any Time." - www.actualtests.com 4
Oracle 1z0-808 Exam
A.
Encapsulation
B.
Inheritance
C.
Abstraction
D.
Instantiation
E.
Polymorphism
Answer: A
Explanation:
Using the private modifier is the main way that an object encapsulates itself and hide data from the
outside world.
Reference: http://www.tutorialspoint.com/java/java_access_modifiers.htm
QUESTION NO: 6
A.
Make the method at line n1 public.
"Pass Any Exam. Any Time." - www.actualtests.com 5
Oracle 1z0-808 Exam
B.
Make the method at line n2 public.
C.
Make the method at line n3 public.
D.
Make the method at line n3 protected.
E.
Make the method at line n4 public.
Answer: C,D
Explanation:
QUESTION NO: 7
Given:
A.
4W 100 Auto
4W 150 Manual
B.
Null 0 Auto
4W 150 Manual
C.
Compilation fails only at line n1
D.
Compilation fails only at line n2
E.
Compilation fails at both line n1 and line n2
Answer: C
Explanation:
QUESTION NO: 8
fragment:
Which two modifications should you make so that the code compiles successfully?
"Pass Any Exam. Any Time." - www.actualtests.com 7
Oracle 1z0-808 Exam
A.
Option A
B.
Option B
C.
Option C
D.
Option D
E.
Option E
Answer: A,C
Explanation:
QUESTION NO: 9
Any amount of electricity used by a customer (represented by an instance of the customer class)
must contribute to the customer's bill (represented by the member variable bill) through the
method use Electricity method. An instance of the customer class should never be able to tamper
with or decrease the value of the member variable bill.
A.
Option A
B.
Option B
C.
Option C
D.
"Pass Any Exam. Any Time." - www.actualtests.com 9
Oracle 1z0-808 Exam
Option D
Answer: A,C
Explanation:
QUESTION NO: 10
A.
Match 1
B.
Match 2
C.
No Match
D.
A NullPointerException is thrown at runtime.
Answer: B
Explanation:
QUESTION NO: 11
Given:
A.
Option A
B.
Option B
C.
Option C
D.
Option D
Answer: C
Explanation:
QUESTION NO: 12
A.
ABCD
B.
ACD
C.
ABCC
D.
ABD
E.
ABDC
Answer: E
Explanation:
QUESTION NO: 13
Given:
Which code fragment should you use at line n1 to instantiate the dvd object successfully?
A.
Option A
B.
Option B
C.
Option C
D.
Option D
Answer: C
"Pass Any Exam. Any Time." - www.actualtests.com 13
Oracle 1z0-808 Exam
Explanation:
QUESTION NO: 14
Which option can replace xxx to enable the code to print 135?
A.
int e = 0; e < = 4; e++
B.
int e = 0; e < 5; e + = 2
C.
int e = 1; e < = 5; e + = 1
D.
int e = 1; e < 5; e+ =2
Answer: B
Explanation:
QUESTION NO: 15
A.
Encapsulation ensures that classes can be designed so that only certain fields and methods of an
object are accessible from other objects.
B.
Encapsulation ensures that classes can be designed so that their methods are inheritable.
C.
D.
Encapsulation ensures that classes can be designed so that if a method has an argument MyType
x, any subclass of MyType can be passed to that method.
Answer: A
Explanation:
QUESTION NO: 16
Which code fragment, when inserted at line 2, enables the code to compile?
A.
Option A
B.
Option B
C.
Option C
D.
Option D
E.
Option E
Answer: E
Explanation:
QUESTION NO: 17
Which three lines, when inserted independently at line n1, cause the program to print a 0 balance?
A.
this.amount = 0;
B.
amount = 0;
C.
acct (0) ;
D.
acct.amount = 0;
E.
acct. getAmount () = 0;
F.
acct.changeAmount(0);
G.
acct.changeAmount(-acct.amount);
H.
acct.changeAmount(-acct.getAmount());
Answer: A,C,D
QUESTION NO: 18
A.
Option A
B.
Option B
C.
Option C
Answer: D
Explanation:
QUESTION NO: 19
A.
Reading Card
Checking Card
B.
Compilation fails only at line n1.
C.
Compilation fails only at line n2.
D.
Compilation fails only at line n3.
E.
Compilation fails at both line n2 and line n3.
Answer: D
Explanation:
QUESTION NO: 20
A.
Replace line 6 with System, out. print (--x) ;
B.
At line 7, insert x --;
C.
Replace line 6 with --x; and, at line 7, insert system, out. print (x);
D.
Replace line 12 With return (x > 0) ? false: true;
Answer: A
Explanation:
QUESTION NO: 21
A.
Replace line 5 With String opt = "true";
B.
Replace line 5 with boolean opt = l;
C.
At line 9, remove the break statement.
D.
Remove the default section.
Answer: A
Explanation:
QUESTION NO: 22
A.
543210
B.
54321
C.
421
D.
5
E.
Nothing is printed
Answer: D
Explanation:
QUESTION NO: 23
A.
100
B.
101
C.
102
D.
103
Answer: E
Explanation:
QUESTION NO: 24
Given:
A.
97 98
B.
97 98
D.
A NullPointerException is thrown at runtime.
E.
An ArraylndexOutOfBoundsException is thrown at runtime.
Answer: A
Explanation:
QUESTION NO: 25
Which two modifications, when made independently, enable the code to print joe:true: 100.0?
A.
Option A
B.
Option B
C.
Option C
D.
Option D
E.
Option E
Answer: A,C
Explanation:
QUESTION NO: 26
"Pass Any Exam. Any Time." - www.actualtests.com 25
Oracle 1z0-808 Exam
Given the code fragment:
A.
[Robb, Rick, Bran]
B.
[Robb, Rick]
C.
[Robb, Bran, Rick, Bran]
D.
An exception is thrown at runtime.
Answer: A
Explanation:
QUESTION NO: 27
Given:
A.
CBA
B.
C
C.
ABC
D.
Compilation fails at line n1 and line n2
Answer: C
Explanation:
QUESTION NO: 28
Given:
A.
3456
B.
3436
C.
5456
D.
3646
Answer: C
Explanation:
QUESTION NO: 29
Which code fragment, when inserted at line 3, enables the code to print 10:20?
A.
int[] array n= new int[2];
B.
int[] array;
array = int[2];
C.
int array = new int[2];
D.
int array [2] ;
Answer: B
Explanation:
QUESTION NO: 30
B.
A B C D Work done
C.
A Work done
D.
Compilation fails
Answer: C
Explanation:
QUESTION NO: 31
A.
Improves the program structure because the error handling code is separated from the normal
program function
B.
Provides a set of standard exceptions that covers all the possible errors
C.
Improves the program structure because the programmer can choose where to handle exceptions
D.
Improves the program structure because exceptions must be handled in the method in which they
occurred
E.
Allows the creation of new exceptions that are tailored to the particular program being created
Answer: A,C,D
Reference: http://javajee.com/introduction-to-exceptions-in-java
QUESTION NO: 32
A.
Option A
B.
Option B
C.
Option C
D.
Option D
Answer: C
Explanation:
QUESTION NO: 33
Given:
A.
Option A
B.
Option B
"Pass Any Exam. Any Time." - www.actualtests.com 32
Oracle 1z0-808 Exam
C.
Option C
D.
Option D
Answer: B
Explanation:
QUESTION NO: 34
A.
24
B.
0246
C.
024
D.
Compilation fails
Answer: C
Explanation:
QUESTION NO: 35
Assume that the system date is June 20, 2014. What is the result?
A.
Option A
B.
Option B
C.
Option C
D.
Option D
Answer: A
Explanation:
QUESTION NO: 36
Which code fragment, when inserted at line 9, enables the code to print true?
B.
String str2 = new String (str1);
C.
String str2 = sb1. toString ();
D.
String str2 = "Duke";
Answer: A
Explanation:
QUESTION NO: 37
A.
10 : 10
B.
5:5
C.
5 : 10
Answer: A
Explanation:
QUESTION NO: 38
If the value of the qty variable is greater than or equal to 90, discount = 0.5
If the value of the qty variable is between 80 and 90, discount = 0.2
Which two code fragments can be independently placed at line n1 to meet the requirements?
A.
Option A
C.
Option C
D.
Option D
E.
Option E
Answer: A,C
Explanation:
QUESTION NO: 39
Given:
javac Test.Java
A.
Success
B.
Failure
C.
D.
An exception is thrown at runtime
Answer: B
Explanation:
QUESTION NO: 40
Which three statements describe the object-oriented features of the Java language?
A.
Objects cannot be reused.
B.
A subclass can inherit from a superclass.
C.
Objects can share behaviors with other objects.
D.
A package must contain more than one class.
E.
Object is the root class of all other objects.
F.
A main method must be declared in every class.
Answer: B,C,F
Reference: http://www.javaworld.com/article/2075459/java-platform/java-101--object-oriented-
language-basics--part-5--object-and-its-methods.html (see the sub title, Object is root of all
classes not all other objects)
QUESTION NO: 41
A.
4
B.
3
C.
4
D.
5
E.
4
F.
4
21
Answer: E
Explanation:
QUESTION NO: 42
You are developing a banking module. You have developed a class named ccMask that has a
maskcc method.
You must ensure that the maskcc method returns a string that hides all digits of the credit card
number except the four last digits (and the hyphens that separate each group of four digits).
Which two code fragments should you use at line n1, independently, to achieve this requirement?
A.
Option A
B.
Option B
C.
Option C
D.
Option D
Answer: B,C
Explanation:
QUESTION NO: 43
"Pass Any Exam. Any Time." - www.actualtests.com 40
Oracle 1z0-808 Exam
Given:
Acc.java:
A.
Both p and s are accessible by obj.
B.
Only s is accessible by obj.
C.
Both r and s are accessible by obj.
D.
p, r, and s are accessible by obj.
Answer: B
Explanation:
QUESTION NO: 44
Given:
A.
Base
DerivedA
B.
Base
DerivedB
C.
DerivedB
D.
DerivedB
DerivedA
E.
A classcast Exception is thrown at runtime.
Answer: C
Explanation:
QUESTION NO: 45
A.
Execution terminates in the first catch statement, and caught a RuntimeException is printed to the
console.
B.
Execution terminates in the second catch statement, and caught an Exception is printed to the
console.
C.
A runtime error is thrown in the thread "main".
D.
"Pass Any Exam. Any Time." - www.actualtests.com 43
Oracle 1z0-808 Exam
Execution completes normally, and Ready to use is printed to the console.
E.
The code fails to compile because a throws keyword is required.
Answer: C
Explanation:
QUESTION NO: 46
Given:
A.
Option A
B.
Option B
C.
Option C
D.
Option D
Answer: D
"Pass Any Exam. Any Time." - www.actualtests.com 44
Oracle 1z0-808 Exam
Explanation:
QUESTION NO: 47
Which code fragment, when inserted at line n1, enables the code to print Hank?
A.
checkAge (iList, ( ) -> p. get Age ( ) > 40);
B.
checkAge(iList, Person p -> p.getAge( ) > 40);
C.
checkAge (iList, p -> p.getAge ( ) > 40);
D.
checkAge(iList, (Person p) -> { p.getAge() > 40; });
Answer: C
QUESTION NO: 48
A.
ABC
B.
ABCDE
C.
ABDE
D.
Compilation fails.
Answer: C
Explanation:
QUESTION NO: 49
A.
true true
B.
true false
C.
false false
D.
false true
Answer: C
Explanation:
QUESTION NO: 50
Which code fragment, when inserted at line n1, enables the App class to print Equal?
A.
Option A
B.
Option B
C.
Option C
D.
Option D
Answer: B
Explanation:
QUESTION NO: 51
Given:
A.
Option A
B.
Option B
C.
Option C
D.
Option D
QUESTION NO: 52
A.
Element 0
Element 1
B.
Null element 0
Null element 1
C.
Null
Null
D.
A NullPointerException is thrown at runtime.
Answer: D
Explanation:
QUESTION NO: 53
"Pass Any Exam. Any Time." - www.actualtests.com 50
Oracle 1z0-808 Exam
Given:
A.
10:20
B.
0:20
C.
Compilation fails at line n1
Answer: D
Explanation:
QUESTION NO: 54
Given the definitions of the MyString class and the Test class:
A.
Option A
B.
Option B
C.
Option C
Answer: C
Explanation:
QUESTION NO: 55
A.
Line 7
B.
Line 8
C.
Line 9
D.
Line 10
E.
Line 11
F.
Line 12
Answer: A,D,F
QUESTION NO: 56
Given:
A.
int main 1
B.
Object main 1
C.
String main 1
D.
Compilation fails
E.
An exception is thrown at runtime
Answer: C
Explanation:
QUESTION NO: 57
Which option represents the state of the num array after successful completion of the outer loop?
A.
Option A
B.
Option B
C.
Option C
"Pass Any Exam. Any Time." - www.actualtests.com 55
Oracle 1z0-808 Exam
D.
Option D
Answer: A
Explanation:
QUESTION NO: 58
A.
Jesse 25
Walter 52
B.
Compilation fails only at line n1
C.
Compilation fails only at line n2
D.
"Pass Any Exam. Any Time." - www.actualtests.com 56
Oracle 1z0-808 Exam
Compilation fails at both line n1 and line n2
Answer: B
Explanation:
QUESTION NO: 59
A.
Option A
B.
Option B
C.
Option C
D.
Option D
E.
Option E
Answer: C
Explanation:
QUESTION NO: 60
You are asked to develop a program for a shopping application, and you are given the following
information:
"Pass Any Exam. Any Time." - www.actualtests.com 58
Oracle 1z0-808 Exam
The application must contain the classes Toy, EduToy, and ConsToy. The Toy class is the
superclass of the other two classes.
Which definition of the Toy class adds a valid layer of abstraction to the class hierarchy?
A.
Option A
B.
Option B
C.
Option C
D.
Option D
Answer: A
Explanation:
QUESTION NO: 61
A.
15, 60, 45, 90, 75
B.
15, 90, 45, 90, 75
C.
15, 30, 75, 60, 90
D.
15, 30, 90, 60, 90
E.
15, 4, 45, 60, 90
Answer: C
Explanation:
QUESTION NO: 62
Which two code fragments, independently, print each element in this array?
A.
Option A
B.
Option B
C.
Option C
D.
Option D
E.
Option E
F.
Option F
Answer: B,E
Explanation:
A.
Only the A.Java file compiles successfully.
B.
Only the B.java file compiles successfully.
C.
Only the C.java file compiles successfully.
D.
The A.Java and B.java files compile successfully.
E.
The B.java and C.java files compile successfully.
F.
The A.Java and C.java files compile successfully.
Answer: A
Explanation:
2. Process all the elements of the array in the reverse order of entry.
A.
Requirements 1, 2, and 3 can be implemented by using the enhanced for loop.
B.
Requirements 1, 2, and 3 can be implemented by using the standard for loop.
C.
Requirements 2 and 3 CANNOT be implemented by using the standard for loop.
D.
Requirement 1 can be implemented by using the enhanced for loop.
E.
Requirement 3 CANNOT be implemented by using either the enhanced for loop or the standard
for loop.
Answer: D,E
Explanation:
QUESTION NO: 65
Given:
A.
400 200
B.
200 200
C.
400 400
D.
Compilation fails.
Answer: A
Explanation:
QUESTION NO: 66
A.
Option A
B.
Option B
C.
Option C
D.
Option D
E.
Option E
Answer: E
Explanation:
QUESTION NO: 67
A.
It can run on any platform.
B.
It can run on any platform only if it was compiled for that platform.
C.
It can run on any platform that has the Java Runtime Environment.
D.
"Pass Any Exam. Any Time." - www.actualtests.com 65
Oracle 1z0-808 Exam
It can run on any platform that has a Java compiler.
E.
It can run on any platform only if that platform has both the Java Runtime Environment and a Java
compiler.
Answer: D
Reference: http://www.math.uni-hamburg.de/doc/java/tutorial/getStarted/intro/definition.html
Explanation:
Java bytecodes help make "write once, run anywhere" possible. You can compile your program
into bytecodes on any platform that has a Java compiler. The bytecodes can then be run on any
implementation of the Java VM. That means that as long as a computer has a Java VM, the same
program written in the Java programming language can run on Windows 2000, a Solaris
workstation, or on an iMac.
QUESTION NO: 68
Given:
A.
1
B.
2
C.
3
Answer: A
Explanation:
QUESTION NO: 69
Given:
A.
Area is 6.0
B.
Area is 3.0
C.
Compilation fails at line n1
D.
Compilation fails at line n2.
Answer: D
Explanation:
Which three code fragments can be independently inserted at line n1 to enable the code to print
one?
A.
Byte x = 1;
B.
short x = 1;
C.
String x = "1";
D.
Long x = 1;
E.
Double x = 1;
F.
Integer x = new Integer ("1");
Answer: A,B,F
Explanation:
QUESTION NO: 71
Given:
"Pass Any Exam. Any Time." - www.actualtests.com 68
Oracle 1z0-808 Exam
A.
True false
B.
True null
C.
Compilation fails
D.
A NullPointerException is thrown at runtime
Answer: A
Explanation:
QUESTION NO: 72
Given the following code for the classes MyException and Test:
B.
B
C.
Either A or B
D.
AB
E.
A compile time error occurs at line n1
Answer: B
Explanation:
QUESTION NO: 73
Given:
A.
myStr: 9009, myNum: 9009
"Pass Any Exam. Any Time." - www.actualtests.com 70
Oracle 1z0-808 Exam
B.
myStr: 7007, myNum: 7007
C.
myStr: 7007, myNum: 9009
D.
Compilation fails
Answer: C
Explanation:
QUESTION NO: 74
A.
Faster code at runtime
B.
More efficient code at runtime
C.
More dynamic code at runtime
D.
More flexible and reusable code
E.
Code that is protected from extension by other classes
Answer: B,D
Reference: https://www.cs.princeton.edu/courses/archive/fall98/cs441/mainus/node5.html
QUESTION NO: 75
A.
1:2:3:4:5:
B.
1:2:3:
C.
Compilation fails.
D.
An ArrayoutofBoundsException is thrown at runtime.
Answer: A
Explanation:
QUESTION NO: 76
Given:
A.
true:true
B.
true:false
C.
false:true
D.
false:false
Answer: C
Explanation:
QUESTION NO: 77
Which two options fail to compile when placed at line n1 of the main method?
A.
employee.salary = 50_000;
B.
director.salary = 80_000;
C.
employee.budget = 200_000;
D.
manager.budget = 1_000_000;
E.
manager.stockOption = 500;
F.
director.stockOptions = 1_000;
Answer: C,E
Explanation:
Which one of the following code examples uses valid Java syntax?
A.
Option A
B.
Option B
C.
Option C
D.
Option D
Answer: A
Reference: https://docs.oracle.com/javase/tutorial/getStarted/application/
A.
1324
B.
2413
C.
3142
D.
4231
Answer: C
Explanation:
QUESTION NO: 80
Given:
A.
An exception is thrown at runtime.
B.
Initialized
Started
Initialized
C.
Initialized
Started
D.
Compilation fails.
Answer: D
Explanation:
QUESTION NO: 81
A.
Answer = 0
B.
Invalid calculation
C.
Compilation fails only at line n1.
D.
Compilation fails only at line n2.
E.
Compilation fails only at line n1 and line2.
Answer: E
Explanation:
QUESTION NO: 82
Given:
A.
100 0 : 100 200:
B.
100 0 : 100 0 :
C.
100 200 : 100 200 :
D.
100 200 : 100 0 :
Answer: D
Explanation:
QUESTION NO: 83
Given:
A.
e, e
i, o
B.
a, e
i, o
C.
a,e
o, o
D.
e, e
o, o
Answer: C
Explanation:
QUESTION NO: 84
A.
Compilation fails.
B.
10 Hello Universe!
C.
10 Hello World!
D.
9 Hello World!
Answer: C
Explanation:
QUESTION NO: 85
Given:
A.
Compilation fails.
B.
"Pass Any Exam. Any Time." - www.actualtests.com 81
Oracle 1z0-808 Exam
11
C.
8
D.
9
E.
10
Answer: D
Explanation:
QUESTION NO: 86
Given:
javac Test.java
A.
TRUE null
B.
true false
C.
false false
D.
true true
Answer: D
Explanation:
QUESTION NO: 87
A.
Replace line n1 with:
"Pass Any Exam. Any Time." - www.actualtests.com 83
Oracle 1z0-808 Exam
import p1.A;
import p1.A;
import p1.p2.B;
B.
Replace line n1 with:
import p1;
import p1;
import p1.p2;
C.
Replace line n1 with:
import p1.A;
import p1.*;
D.
Replace line n1 with:
import p1.*;
import p1.p2.*;
Answer: D
Explanation:
QUESTION NO: 88
Which statement will empty the contents of a StringBuilder variable named sb?
A.
B.
sb. delete (0, sb. size () );
C.
sb. delete (0, sb. length () );
D.
sb. removeAll ();
Answer: C
Explanation:
Given:
A) stuff.equals (“TV”) ? res= “Walter” : stuff.equals (“Movie”) ? res = “White” : res = “No Result”;
B) res = stuff.equals (“TV”) ? “Walter” else stuff.equals (“Movie”)? “White” : “No Result”;
Answer:
B
"Pass Any Exam. Any Time." - www.actualtests.com 85
Oracle 1z0-808 Exam
QUESTION NO: 90
Given:
Which code fragment, when inserted at line 14, enables the code to print Mike Found?
A.
int f = ps.indexOf (p2)
B.
int f = ps.indexOf (Patient (“Mike”) );
C.
int f = ps.indexOf (new Patient “Mike”) );
D.
"Pass Any Exam. Any Time." - www.actualtests.com 86
Oracle 1z0-808 Exam
Patient p = new Patient (“Mike”);
Answer: A
Explanation:
QUESTION NO: 91
A.
It must contain the default section.
B.
The break statement, at the end of each case block, is mandatory.
C.
Its case label literals can be changed at runtime.
D.
Its expression must evaluate to a single value.
Answer: D
Reference: http://www.dummies.com/programming/java/switch-statements-in-java/
QUESTION NO: 92
Given:
Which two modifications enable the code to print the following output?
Canine 60 Long
Feline 80 Short
A.
Replace line n1 with:
this.bounds = bounds;
B.
Replace line n1 with:
this.bounds = bounds;
super ();
C.
Replace line n2 with:
this (bounds);
D.
Replace line n1 with:
this.bounds = bounds
E.
Replace line n2 with:
this.bounds = bounds;
Answer: A,E
Explanation:
QUESTION NO: 93
A.
Invalid Name
B.
Invalid Name
omas
C.
Invalid Name
omas
null
null
D.
omas
ter
seph
Answer: C
Explanation:
Test.java
A.
Compilation fails in the Employee class.
B.
null : 0: 0
Jack : 50 : 0
Chloe : 40 : 5000
C.
"Pass Any Exam. Any Time." - www.actualtests.com 91
Oracle 1z0-808 Exam
null : 0 : 0
Jack : 50 : 2000
Chloe : 40 : 5000
D.
Compilation fails in the Test class.
E.
Both the Employee class and the test class fail to compile.
Answer: E
Explanation:
QUESTION NO: 95
A.
Replace line n1 with:
import p1.*;
B.
Replace line n1 with:
import p1. A;
import p1.*;
C.
Replace line n1 with:
import p1. A;
import p1. A;
D.
Replace line n1 with:
import p1;
import p1;
Answer: C
Explanation:
QUESTION NO: 96
Given:
"Pass Any Exam. Any Time." - www.actualtests.com 93
Oracle 1z0-808 Exam
A.
A
B.
A
C.
C
D.
A ClassCastException is thrown only at line n1.
Answer: B
Explanation:
QUESTION NO: 97
Given:
A.
int sum is 30
B.
int sum is 30
C.
integer sum is 30
Answer: D
Explanation:
QUESTION NO: 98
Which two modifications should you make so that the code compiles successfully?
A.
Option A
C.
Option C
D.
Option D
E.
Option E
Answer: E
Explanation:
QUESTION NO: 99
You are asked to create a method that accepts an array of integers and returns the highest value
from that array.
A.
public int findMax (int [] numbers)
B.
static int[] findMax (int max)
C.
static int findMax (int [] numbers)
D.
"Pass Any Exam. Any Time." - www.actualtests.com 97
Oracle 1z0-808 Exam
final int findMax (int [] )
Answer: A
Explanation:
Which three statements are true about the structure of a Java class?
A.
A public class must have a main method.
B.
A class can have only one private constructor.
C.
A method can have the same name as a field.
D.
A class can have overloaded static methods.
E.
The methods are mandatory components of a class.
F.
The fields need not be initialized before use.
Answer: A,C,E
Explanation:
A.
Option A
B.
Option B
C.
Option C
D.
Option D
Answer: C
Explanation:
Given:
A.
Compilation fails at line n3 and line n4.
B.
Compilation fails at line n1 and line n2.
C.
Welcome Visit Count:1
D.
Welcome Visit Count:1
Answer: B
Explanation:
A.
Compilation fails at both line n1 and line n2.
B.
Compilation fails only at line n2.
C.
Compilation fails only at line n1.
D.
Jesse 25
Walter 52
Answer: D
Explanation:
A.
5:5
B.
10 : 10
C.
5 : 10
D.
Compilation fails.
Answer: B
Reference:
A.
A NullPointerException is thrown at runtime.
B.
[1, 2, 4]
C.
[1, 2, 4, null ]
D.
[1, 3, 4, null ]
E.
[1, 3, 4 ]
F.
Compilation fails.
Answer: F
Explanation:
Given:
B.
0 0 30 40
C.
Compilation fails.
D.
An exception is thrown at runtime.
Answer: C
Explanation:
A.
Option A
B.
Option B
C.
Option C
D.
Option D
Answer: D
Explanation:
Given:
A.
c=
b = false
f = 0.0
B.
c= null
b = true
f = 0.0
C.
b = false
f = 0.0f
D.
c= null
b = false
f = 0.0F
Answer: C
Explanation:
A.
Only unchecked exceptions can be rethrown.
B.
All subclasses of the RuntimeException class are recoverable.
C.
The parameter in a catch block is of Throwable type.
D.
All subclasses of the RuntimeException class must be caught or declared to be thrown.
E.
All subclasses of the Exception class except the RuntimeException class are checked exceptions.
F.
All subclasses of the Error class are checked exceptions and are recoverable.
Answer: C,E,F
Explanation:
Which code fragment, inserted at line n1, pints The Top element: 30?
A.
Option A
B.
Option B
C.
Option C
E.
Option E
Answer: A
Explanation:
A.
An exception is thrown at runtime.
B.
-1
C.
5
D.
0
Answer: A
Explanation:
Given:
"Pass Any Exam. Any Time." - www.actualtests.com 109
Oracle 1z0-808 Exam
A.
false, false
B.
false, true
C.
true, false
D.
true, true
Answer: B
Explanation:
A.
Error class is unextendable.
B.
Error class is extendable.
C.
Error is a RuntimeException.
"Pass Any Exam. Any Time." - www.actualtests.com 110
Oracle 1z0-808 Exam
D.
Error is an Exception.
E.
Error is a Throwable.
Answer: B,C
Explanation:
A.
Compilation fails.
B.
0 Found
C.
1 Found
D.
3 Found
Answer: D
A.
An exception is thrown at runtime.
B.
07-31-2014
C.
2014-07-31
D.
2014-09-30
Answer: C
Explanation:
Given:
javac Test.java
java Test
A.
Java SE
B.
Java EE
C.
Compilation fails at line n1.
D.
A NullPointerException is thrown at runtime.
Answer: A
Explanation:
Given:
Book1.readBook();
A.
Option A
B.
Option B
C.
Option C
D.
Option D
Answer: A
Explanation:
Which three pieces of code, when inserted independently, set the value of amount to 100?
A.
Option A
B.
Option B
C.
Option C
D.
Option D
E.
Option E
F.
Option F
Answer: C,D,E
A.
Compilation fails only at line n2.
B.
RTool::export
Tool::export
C.
"Pass Any Exam. Any Time." - www.actualtests.com 117
Oracle 1z0-808 Exam
Tool::export
Tool:export
D.
Compilation fails only at line n1.
E.
Compilation fails at both line n1 and line n2.
Answer: E
Explanation:
A.
An exception is thrown at runtime.
B.
Compilation fails.
C.
13480.0
D.
13480.02
Answer: C
Explanation:
Given:
"Pass Any Exam. Any Time." - www.actualtests.com 118
Oracle 1z0-808 Exam
A.
300:300
200:300
B.
300:100
200:300
C.
300:0
0:300
D.
200:300
200:300
Answer: D
Explanation:
Given:
A.
C2C2
B.
C1C2
C.
C1C1
D.
Compilation fails
Answer: A
"Pass Any Exam. Any Time." - www.actualtests.com 120
Oracle 1z0-808 Exam
Explanation:
Given:
Which two sets of actions, independently, enable the code fragment to print Fit?
A.
At line n1 insert: import clothing.Shirt;
B.
At line n1 insert: import clothing.*;
D.
At line n1 no changes required.
E.
At line n1 insert: import clothing;
Answer: A
Explanation:
And,
B.
After line 11, two objects are eligible for garbage collection.
C.
After line 11, one object is eligible for garbage collection.
D.
After line 11, none of the objects are eligible for garbage collection.
Answer: C
Explanation:
A.
3
B.
4
"Pass Any Exam. Any Time." - www.actualtests.com 123
Oracle 1z0-808 Exam
C.
-1
D.
Compilation fails.
Answer: B
Explanation:
A.
2012-02-10
B.
2012-02-11
C.
Compilation fails
D.
A DateTimeException is thrown at runtime.
Answer: C
Explanation:
Given:
A.
10 : 30 : 6
B.
10 : 22 : 22
C.
10 : 22 : 20
D.
10 : 22 : 6
Answer: B
Explanation:
Explanation
A.
Compilation fails at line n2.
B.
Read Book
C.
Read E-Book
D.
Compilation fails at line n1.
E.
Compilation fails at line n3.
Answer: B
Explanation:
Which two changes would encapsulate this class and ensure that the area field is always equal to
length * height whenever the Rectangle class is used?
A.
Call the setArea method at the end of the setHeight method.
B.
Call the setArea method at the beginning of the setHeight method.
C.
Call the setArea method at the end of the setLength method.
D.
Call the setArea method at the beginning of the setLength method.
E.
Change the setArea method to private.
F.
Change the area field to public.
Answer: A,E
Explanation:
A.
(green, red, yellow, cyan)
B.
(green, blue, yellow, cyan)
C.
(green, red, cyan, yellow)
D.
An IndexOutOfBoundsException is thrown at runtime.
Answer: C
Explanation:
A.
public static void insertToy() {
B.
public abstract Toy getToy() {
C.
public void printToy();
D.
public int calculatePrice() {
return price;
E.
public abstract int computeDiscount();
Answer: C,D,E
Explanation:
Given:
A.
Compilation fails.
B.
35
C.
00
D.
9 25
Answer: B
Explanation:
Which two code fragments can be independently inserted at line n1 to enable the code to print the
elements of the array in reverse order?
A.
while (x > 0) {
x--;
System.out.print(array[x]);
B.
do {
x--;
System.out.print(array[x]);
C.
while (x >= 0) {
System.out.print(array[x]);
x--;
D.
do {
System.out.print(array[x]);
--x;
E.
while (x > 0) {
System.out.print(array[--x]);
}
"Pass Any Exam. Any Time." - www.actualtests.com 131
Oracle 1z0-808 Exam
Answer: B,E
Explanation:
Given:
class Test
int a1;
a = a * a;
s.append(“ “ + s);
item.a1 = 11;
Integer i = 10;
doProduct(i);
doString(sb);
doProduct(item.a1);
System.out.println(i + “ “ + sb + “ “ + item.a1);
A.
10 Hello Hello 11
B.
10 Hello Hello 121
C.
100 Hello 121
D.
100 Hello Hello 121
E.
10 Hello 11
Answer: B
Explanation:
A.
Compilation fails.
B.
Hi removed
C.
An UnsupportedOperationException is thrown at runtime.
D.
The program compiles, but it prints nothing.
"Pass Any Exam. Any Time." - www.actualtests.com 133
Oracle 1z0-808 Exam
Answer: A
Explanation:
A.
abstract class A3 {
public A3(){}
B.
final class A1 {
public A1(){}
C.
public class A2 {
private A2(){}
D.
class A4 {
E.
final abstract class A5 {
Answer: C,E
Explanation:
Given:
A.
null
Richard
Donald
B.
Richard
Donald
"Pass Any Exam. Any Time." - www.actualtests.com 135
Oracle 1z0-808 Exam
C.
Compilation fails.
D.
An ArrayIndexOutOfBoundsException is thrown at runtime.
E.
A NullPointerException is thrown at runtime.
Answer: A
Explanation:
Which line of code, when inserted in place of //line n1, adds an X into the grid so that the grid
contains three consecutive X’s?
A.
grid[1][3] = ‘X’;
B.
grid[3][1] = ‘X’;
C.
"Pass Any Exam. Any Time." - www.actualtests.com 136
Oracle 1z0-808 Exam
grid[0][2] = ‘X’;
D.
grid[2][0] = ‘X’;
E.
grid[1][2] = ‘X’;
Answer: C
Explanation:
Given:
A.
Hello Log 1:0
B.
Hello Log 2:1
C.
Welcome Log 2:1
D.
Welcome Log 1:0
Answer: C
"Pass Any Exam. Any Time." - www.actualtests.com 137
Oracle 1z0-808 Exam
Explanation:
Which command-line arguments should you pass to the program to obtain the following output?
Arg is 2
A.
java MyFile 1 3 2 2
B.
java MyFile 2 2 2
C.
java MyFile 1 2 2 3 4
D.
java MyFile 0 1 2 3
Answer: A
Explanation:
A.
1234
followed by an ArrayIndexOutOfBoundsException
B.
123
C.
1234
D.
Compilation fails.
Answer: A
Explanation:
Given:
A.
Compilation fails.
B.
false true
C.
true false
D.
true true
E.
false false
Answer: B
Explanation: