Want to Pass 1z0-808 Exam In Next HOURS? Get it now →
April 21, 2017

Apr 2017 updated: Testking Oracle 1z0-808 free practice test 81-90

Q81. Given: 

public class Test { 

static boolean bVar; 

public static void main(String[] args) { 

boolean bVar1 = true; 

int count =8; 

do { 

System.out.println("Hello Java! " +count); 

if (count >= 7) { 

bVar1 = false; 

} while (bVar != bVar1 && count > 4); 

count -= 2; 

What is the result? 

A. Hello Java! 8 Hello Java! 6 Hello Java! 4 

B. Hello Java! 8 Hello Java! 6 

C. Hello Java! 8 

D. Compilation fails 

Answer:

Explanation: Hello Java! 8 


Q82. Given: 

What will be the output? 

A. Option A 

B. Option B 

C. Option C 

D. Option D 

Answer:


Q83. Given the code fragment: 

float x = 22.00f % 3.00f; 

int y = 22 % 3; 

System.out.print(x + ", "+ y); 

What is the result? 

A. 1.0, 1 

B. 1.0f, 1 

C. 7.33, 7 

D. Compilation fails 

E. An exception is thrown at runtime 

Answer:


Q84. Which of the following can fill in the blank in this code to make it compile? (Select 2 options.) 

A. On line 1, fill in throws 

B. On line 1, fill in throws new 

C. On line 2, fill in throw new 

D. On line 2, fill in throws 

E. On line 2, fill in throws new 

Answer: A,C 

Explanation: 

Option A and C are the correct answer. 

In a method declaration, the keyword throws is used. So here at line 1 we have to use 

option A. 

To actually throw an exception, the keyword throw is used and a new exception is created, 

so at line 2 we have to use throw and new keywords, which is option C. Finally it will look 

like; 

public void method() throws Exception { 

throw new Exception0; 

REFERENCE : httpsy/docs.oracle.com/javase/tutorial/essential/io/fileOps.html#exception 

The correct answer is: On line 1, fill in throws. On line 2, fill in throw new 


Q85. Given: 

public class Test { 

public static void main(String[] args) { 

int arr[] = new int[4]; 

arr[0] = 1; 

arr[1] = 2; 

arr[2] = 4; 

arr[3] = 5; 

int sum = 0; 

try { 

for (int pos = 0; pos <= 4; pos++) { 

sum = sum + arr[pos]; 

} catch (Exception e) { 

System.out.println("Invalid index"); 

System.out.println(sum); 

What is the result? 

A. 12 

B. Invalid Index 

C. Invalid Index 

D. Compilation fails 

Answer:

Explanation: The loop ( for (int pos = 0; pos <= 4; pos++) { ), it should be pos <= 3, causes an exception, which is caught. Then the correct sum is printed. 


Q86. Given the following two classes: 

How should you write methods in the ElectricAccount class at line n1 so that the member variable bill is always equal to the value of the member variable kwh multiplied by the member variable rate? 

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 useElectricity 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. Option D 

Answer:


Q87. Consider following interface. 

Which of the following will create instance of Runnable type? 

A. Runnable run = 0 -> {System.out.println("Run");} 

B. Runnable run = 0 -> System.outprintlnfRun"); 

C. Runnable run = 0 > System.outprintlnfRun"); 

D. Runnable run = > System.ouLprintlnfRun"}; 

E. None of the above. 

Answer:

Explanation: 

Option A is the correct answer. 

To create we have used following method with LocalDate class; 

public static LocalDate of(intyear, int month, intdayOfMonth) 

Here we need to remember that month is not zero based so if you pass 1 for month, then 

month will be January. 

Then we have used period object of 1 day and add to date object which makes current date 

to next day, so final output is 2015-03-27. Hence option A is correct. 


Q88. Given the code fragments: 

Which code fragment, when inserted at line ni, 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:


Q89. Which two items can legally be contained within a java class declaration? 

A. An import statement 

B. A field declaration 

C. A package declaration 

D. A method declaration 

Answer: B,D 

Reference: 

http://docs.oracle.com/javase/tutorial/java/javaOO/methods.html 


Q90. Given the following classes: 

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 



see more http://www.ubraindumps.com/1z0-808-dumps/