aiotestking uk

1z0-808 Exam Questions - Online Test


1z0-808 Premium VCE File

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

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

Q2. Given: 

class Mid { 

public int findMid(int n1, int n2) { 

return (n1 + n2) / 2; 

public class Calc extends Mid { 

public static void main(String[] args) { 

int n1 = 22, n2 = 2; 

// insert code here 

System.out.print(n3); 

Which two code fragments, when inserted at // insert code here, enable the code to compile and print 12? 

A. Calc c = new Calc(); int n3 = c.findMid(n1,n2); 

B. int n3 = super.findMid(n1,n3); 

C. Calc c = new Mid(); int n3 = c.findMid(n1, n2); 

D. Mid m1 = new Calc(); int n3 = m1.findMid(n1, n2); 

E. int n3 = Calc.findMid(n1, n2); 

Answer: A,D 

Explanation: 

Incorrect: 

Not B: circular definition of n3. 

Not C: Compilation error. line Calc c = new Mid(); 

required: Calc 

found: Mid 

Not E: Compilation error. line int n3 = Calc.findMid(n1, n2); 

non-static method findMid(int,int) cannot be referenced from a static context 

Q3. Given: 

Which two code fragments are valid? 

A. Option A 

B. Option B 

C. Option C 

D. Option D 

E. Option E 

Answer: B,C 

Explanation: When an abstract class is subclassed, the subclass usually provides implementations for all of the abstract methods in its parent class (C). However, if it does not, then the subclass must also be declared abstract (B). Note: An abstract class is a class that is declared abstract—it may or may not include abstract methods. Abstract classes cannot be instantiated, but they can be subclassed. 

Q4. Given the code fragment: 

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:

Q5. Given the code fragment: 

int b = 3; 

if ( !(b > 3)) { 

System.out.println("square "); 

}{ 

System.out.println("circle "); 

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

What is the result? 

A. square... 

B. circle... 

C. squarecircle... 

D. Compilation fails. 

Answer:

Q6. Given the following class declarations: 

public abstract class Animal 

public interface Hunter 

public class Cat extends Animal implements Hunter 

public class Tiger extends Cat 

Which answer fails to compile? 

A. Option A 

B. Option B 

C. Option C 

D. Option D 

E. Option E 

Answer:

Explanation: Look at the right side of the declaration ArrayLIst() rather than ArrayList 

Q7. Given: 

What is the result? 

A. 120 

B. 120D 

C. A NumberFormatException will be thrown. 

D. Compilation fails due to error at line 5. 

E. Compilation tails due to error at line 8. 

Answer:

Explanation: 

At line 5, we have created a wrapper object of double by passing 120D, which is convertible to a Double, so there won't be any exception there. But if you check carefully, you can see the variable number is declared inside try block, so the scope of the variable number is limited to that block, so trying to access it outside causes a compile time error. httpsy/docs.oracle.com/javase/tutorial/iava/nutsandbolts/variables.html 

Q8. Given: 

Which inserted at line 11, will provide the following output? 

[21, 15, 11] 

A. list.removelf(e > e%2 != 0); 

B. list.removelf(e -> e%2 != 0); 

C. Ust.removelf(e -> e%2 = 0); 

D. list.remove(e -> e%2 = 0); 

E. None of the above. 

Answer:

Explanation: 

In output we can see that only odd numbers present, so we need to remove only even numbers to get expected output. From Java SE 8, there is new method call removelf which takes predicate object and remove elements which satisfies predicate condition. Predicate has functional method call take object and check if the given condition met or not, if met it returns true, otherwise false. Option C we have passed correct lambda expression to check whether the number is odd or even that matches to the functional method of predicate interface. Option A is incorrect as it is invalid lambda expression. Option B is incorrect as it removes all odd numbers. Option D is incorrect as there is no remove method that takes predicate as argument. https://docs.oracle.eom/javase/8/docs/api/java/util/ArrayList.html 

Q9. Given: 

public class SampleClass { 

public static void main(String[] args) { 

AnotherSampleClass asc = new AnotherSampleClass(); SampleClass sc = new 

SampleClass(); 

sc = asc; 

System.out.println("sc: " + sc.getClass()); 

System.out.println("asc: " + asc.getClass()); 

}} 

class AnotherSampleClass extends SampleClass { 

What is the result? 

A. sc: class Object asc: class AnotherSampleClass 

B. sc: class SampleClass asc: class AnotherSampleClass 

C. sc: class AnotherSampleClass asc: class SampleClass 

D. sc: class AnotherSampleClass asc: class AnotherSampleClass 

Answer:

Q10. Which of the following data types will allow the following code snippet to compile? 

A. long 

B. double 

C. int 

D. float 

E. byte 

Answer: B,D 

Explanation: 

Option B and D are the correct answer. 

Since the variables I and j are floats, resultant will be float type too. So we have to use float 

or primitive type which can hold float, such a primitive type is double, it has wider range 

and also can hold floating point numbers, hence we can use double or float for the blank. 

As explained above options B and D are correct. 

long and int can't be used with floating point numbers so option A is incorrect. 

Option E is incorrect as it have smaller range and also can't be used with floating point 

numbers. 

hnpsy/docs.oracle.com/javase/tutorial/java/javaOO/variables.html