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

Q2. Given the fragments: 

Which line causes a compilation error? 

A. Line n1 

B. Line n2 

C. Line n3 

D. Line n4 

Answer:

Q3. Which statement best describes encapsulation? 

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. Encapsulation ensures that classes can be designed with some fields and methods declared as abstract. 

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:

Q4. Given the class definitions: 

And the code fragment of the main() method, 

What is the result? 

A. Java Java Java 

B. Java Jeve va 

C. Java Jeve ve 

D. Compilation fails 

Answer:

Q5. Given the code fragment: 

What is the result? 

A. 10 8 6 4 2 0 

B. 10 8 6 4 2 

C. AnArithmeticException is thrown at runtime 

D. The program goes into an infinite loop outputting: 10 8 6 4 2 0. . . 

E. Compilation fails 

Answer:

Q6. Which of the following can fill in the blank in this code to make it compile? 

A. abstract 

B. public 

C. default 

D. It will not compile with any as interfaces cannot have non abstract methods. 

E. It will compile without filling the blank. 

Answer:

Explanation: 

From Java SE 8, we can use static and/or default methods in interfaces, but they should be non abstract methods. SO in this case using default in blank is completely legal. Hence option C is correct. Option A is incorrect as given method is not abstract, so can't use abstract there. Options B and E are incorrect as we can't have non abstract method interface if they are not default or static. https;//docs.oraclexom/javase/tutorial/java/Iandl/defaultmethods.html 

Q7. Given: 

What is the result? 

A. Good Day! Good Luck! 

B. Good Day! Good Day! 

C. Good Luck! Good Day! 

D. Good Luck! Good Luck! 

E. Compilation fails 

Answer:

Q8. Given: 

public class FieldInit { 

char c; 

boolean b; 

float f; 

void printAll() { 

System.out.println("c = " + c); 

System.out.println("c = " + b); 

System.out.println("c = " + f); 

public static void main(String[] args) { 

FieldInit f = new FieldInit(); 

f.printAll(); 

What is the result? 

A. c = null 

b = false 

f = 0.0F 

B. c = 0 

b = false 

f = 0.0f 

C. c = null 

b = true 

f = 0.0 

D. c = 

b = false 

f = 0.0 

Answer:

Q9. Given: 

And given the commands: 

javac Test.Java 

Java Test Hello 

What is the result? 

A. Success 

B. Failure 

C. Compilation fails. 

D. An exception is thrown at runtime 

Answer:

Q10. You are developing a banking module. You have developed a class named ccMask that has a maskcc method. 

Given the code fragment:

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